diff --git a/Protocols/Http/Request.php b/Protocols/Http/Request.php index e54855795..ea0a06369 100644 --- a/Protocols/Http/Request.php +++ b/Protocols/Http/Request.php @@ -71,6 +71,12 @@ class Request */ protected static $_enableCache = true; + /** + * Is safe. + * + * @var bool + */ + protected $_isSafe = true; /** * Request constructor. @@ -208,8 +214,8 @@ public function protocolVersion() public function host($without_port = false) { $host = $this->header('host'); - if ($host && $without_port && $pos = \strpos($host, ':')) { - return \substr($host, 0, $pos); + if ($host && $without_port) { + return preg_replace('/:\d{1,5}$/', '', $host); } return $host; } @@ -656,6 +662,15 @@ public function __toString() return $this->_buffer; } + /** + * __wakeup. + * @return void + */ + public function __wakeup() + { + $this->_isSafe = false; + } + /** * __destruct. * @@ -663,7 +678,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 b8323d37b..31673fc12 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,15 @@ public function gc() static::$_handler->gc(static::$lifetime); } + /** + * __wakeup. + * @return void + */ + public function __wakeup() + { + $this->_isSafe = false; + } + /** * __destruct. * @@ -409,6 +425,9 @@ public function gc() */ public function __destruct() { + if (!$this->_isSafe) { + return; + } $this->save(); if (\rand(1, static::$gcProbability[1]) <= static::$gcProbability[0]) { $this->gc(); diff --git a/Worker.php b/Worker.php index 36e3d837c..b5ed58c5d 100644 --- a/Worker.php +++ b/Worker.php @@ -34,7 +34,7 @@ class Worker * * @var string */ - const VERSION = '4.0.45'; + const VERSION = '4.0.46'; /** * Status starting. @@ -1057,7 +1057,10 @@ protected static function formatStatusData($statistics_file) } $status_str = ''; $current_total_request = array(); - $worker_info = \unserialize($info[0]); + $worker_info = []; + try { + $worker_info = unserialize($info[0], ['allowed_classes' => false]); + } catch (Throwable $exception) {} \ksort($worker_info, SORT_NUMERIC); unset($info[0]); $data_waiting_sort = array();