From 562e322fe595b4d3307ff28a96c8c5fbcc284010 Mon Sep 17 00:00:00 2001 From: Fabio Bas Date: Thu, 25 Feb 2016 17:01:17 +0100 Subject: Applied some misc optimizations to class serialization MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Avoid saving in the page state the values of class variables if they’re still the default. Reduces page state size, based on the work initiated in 8dc9d4f7d49bcbeaf4998baf74a4f4459967c1f0 --- framework/TComponent.php | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) (limited to 'framework/TComponent.php') diff --git a/framework/TComponent.php b/framework/TComponent.php index 5901f93d..c2f00696 100644 --- a/framework/TComponent.php +++ b/framework/TComponent.php @@ -1697,16 +1697,6 @@ class TComponent return null; } - /** - * Do not call this method. This is a PHP magic method that will be called automatically - * after any unserialization; it can perform reinitialization tasks on the object. - */ - public function __wakeup() - { - if ($this->_e===null) - $this->_e = array(); - } - /** * Returns an array with the names of all variables of that object that should be serialized. * Do not call this method. This is a PHP magic method that will be called automatically @@ -1717,6 +1707,18 @@ class TComponent $a = (array)$this; $a = array_keys($a); $exprops = array(); + $this->__getZappableSleepProps($exprops); + return array_diff($a, $exprops); + } + + /** + * Returns an array with the names of all variables of this object that should NOT be serialized + * because their value is the default one or useless to be cached for the next page loads. + * Reimplement in derived classes to add new variables, but remember to also to call the parent + * implementation first. + */ + protected function __getZappableSleepProps(&$exprops) + { if($this->_listeningenabled===false) $exprops[] = "\0TComponent\0_listeningenabled"; if($this->_behaviorsenabled===true) @@ -1725,7 +1727,6 @@ class TComponent $exprops[] = "\0TComponent\0_e"; if ($this->_m===null) $exprops[] = "\0TComponent\0_m"; - return array_diff($a,$exprops); } } -- cgit v1.2.3