summaryrefslogtreecommitdiff
path: root/framework/TComponent.php
diff options
context:
space:
mode:
authorFabio Bas <ctrlaltca@gmail.com>2016-02-25 17:01:17 +0100
committerFabio Bas <ctrlaltca@gmail.com>2016-02-25 17:01:17 +0100
commit562e322fe595b4d3307ff28a96c8c5fbcc284010 (patch)
tree4b16f146c8ee931dc084758798cfdb32f64b914b /framework/TComponent.php
parent294682fb45014ba04ce1b193af712208b15a6151 (diff)
Applied some misc optimizations to class serialization
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
Diffstat (limited to 'framework/TComponent.php')
-rw-r--r--framework/TComponent.php23
1 files changed, 12 insertions, 11 deletions
diff --git a/framework/TComponent.php b/framework/TComponent.php
index 5901f93d..c2f00696 100644
--- a/framework/TComponent.php
+++ b/framework/TComponent.php
@@ -1698,16 +1698,6 @@ class TComponent
}
/**
- * 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
* prior to any serialization.
@@ -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);
}
}