diff --git a/Protocols/Http/Request.php b/Protocols/Http/Request.php index 9b950980c..d544ac0d9 100644 --- a/Protocols/Http/Request.php +++ b/Protocols/Http/Request.php @@ -46,7 +46,7 @@ class Request public $properties = array(); /** - * @var int + * @var int */ public static $maxFileUploads = 1024; @@ -71,6 +71,13 @@ class Request */ protected static $_enableCache = true; + /** + * Is safe. + * + * @var bool + */ + protected $_isSafe = true; + /** * Request constructor. @@ -656,6 +663,16 @@ public function __toString() return $this->_buffer; } + /** + * __wakeup. + * + * @return void + */ + public function __wakeup() + { + $this->_isSafe = false; + } + /** * __destruct. * @@ -663,7 +680,7 @@ public function __toString() */ public function __destruct() { - if (isset($this->_data['files'])) { + if (isset($this->_data['files']) && $this->_isSafe) { \clearstatcache(); \array_walk_recursive($this->_data['files'], function($value, $key){ if ($key === 'tmp_name') { diff --git a/Protocols/Http/Session.php b/Protocols/Http/Session.php index 29961e4e1..a0c2417bc 100644 --- a/Protocols/Http/Session.php +++ b/Protocols/Http/Session.php @@ -134,6 +134,13 @@ class Session */ protected $_sessionId = null; + /** + * Is safe. + * + * @var bool + */ + protected $_isSafe = true; + /** * Session constructor. * @@ -402,6 +409,16 @@ public function gc() static::$_handler->gc(static::$lifetime); } + /** + * __wakeup. + * + * @return void + */ + public function __wakeup() + { + $this->_isSafe = false; + } + /** * __destruct. * @@ -409,6 +426,9 @@ public function gc() */ public function __destruct() { + if (!$this->_isSafe) { + return; + } $this->save(); if (\random_int(1, static::$gcProbability[1]) <= static::$gcProbability[0]) { $this->gc();