mirror of
https://github.com/getgrav/grav.git
synced 2026-05-07 01:06:15 +02:00
Improved user serialization to use less memory in the session
This commit is contained in:
@@ -1,3 +1,9 @@
|
||||
# v1.5.6
|
||||
## mm/dd/2018
|
||||
|
||||
1. [](#improved)
|
||||
* Improved user serialization to use less memory in the session
|
||||
|
||||
# v1.5.5
|
||||
## 11/12/2018
|
||||
|
||||
|
||||
@@ -82,4 +82,28 @@ trait CompiledFile
|
||||
|
||||
return parent::content($var);
|
||||
}
|
||||
|
||||
/**
|
||||
* Serialize file.
|
||||
*/
|
||||
public function __sleep()
|
||||
{
|
||||
return [
|
||||
'filename',
|
||||
'extension',
|
||||
'raw',
|
||||
'content',
|
||||
'settings'
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Unserialize file.
|
||||
*/
|
||||
public function __wakeup()
|
||||
{
|
||||
if (!isset(static::$instances[$this->filename])) {
|
||||
static::$instances[$this->filename] = $this;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -286,4 +286,29 @@ class User extends Data
|
||||
|
||||
return 'https://www.gravatar.com/avatar/' . md5($this->email);
|
||||
}
|
||||
|
||||
/**
|
||||
* Serialize user.
|
||||
*/
|
||||
public function __sleep()
|
||||
{
|
||||
return [
|
||||
'items',
|
||||
'storage'
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Unserialize user.
|
||||
*/
|
||||
public function __wakeup()
|
||||
{
|
||||
$this->gettersVariable = 'items';
|
||||
$this->nestedSeparator = '.';
|
||||
|
||||
if (null === $this->blueprints) {
|
||||
$blueprints = new Blueprints;
|
||||
$this->blueprints = $blueprints->get('user/account');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user