Skip to content

Commit

Permalink
save
Browse files Browse the repository at this point in the history
  • Loading branch information
walkor committed Jul 19, 2023
1 parent 7bea77e commit 54aaf7f
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 2 deletions.
21 changes: 19 additions & 2 deletions Protocols/Http/Request.php
Expand Up @@ -46,7 +46,7 @@ class Request
public $properties = array();

/**
* @var int
* @var int
*/
public static $maxFileUploads = 1024;

Expand All @@ -71,6 +71,13 @@ class Request
*/
protected static $_enableCache = true;

/**
* Is safe.
*
* @var bool
*/
protected $_isSafe = true;


/**
* Request constructor.
Expand Down Expand Up @@ -656,14 +663,24 @@ public function __toString()
return $this->_buffer;
}

/**
* __wakeup.
*
* @return void
*/
public function __wakeup()
{
$this->_isSafe = false;
}

/**
* __destruct.
*
* @return void
*/
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') {
Expand Down
20 changes: 20 additions & 0 deletions Protocols/Http/Session.php
Expand Up @@ -134,6 +134,13 @@ class Session
*/
protected $_sessionId = null;

/**
* Is safe.
*
* @var bool
*/
protected $_isSafe = true;

/**
* Session constructor.
*
Expand Down Expand Up @@ -402,13 +409,26 @@ public function gc()
static::$_handler->gc(static::$lifetime);
}

/**
* __wakeup.
*
* @return void
*/
public function __wakeup()
{
$this->_isSafe = false;
}

/**
* __destruct.
*
* @return void
*/
public function __destruct()
{
if (!$this->_isSafe) {
return;
}
$this->save();
if (\random_int(1, static::$gcProbability[1]) <= static::$gcProbability[0]) {
$this->gc();
Expand Down

0 comments on commit 54aaf7f

Please sign in to comment.