From 73f4762a554884bb511c2c6ca8540b24623c51ee Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Mon, 18 Apr 2011 18:23:06 -0400 Subject: [PATCH] Don't serialize protected attrs --- classes/Notice.php | 18 ++++++++++++++++++ classes/Profile.php | 17 +++++++++++++++++ classes/User.php | 17 +++++++++++++++++ 3 files changed, 52 insertions(+) diff --git a/classes/Notice.php b/classes/Notice.php index bcd84501ec..71d4d4ff23 100644 --- a/classes/Notice.php +++ b/classes/Notice.php @@ -2407,4 +2407,22 @@ class Notice extends Memcached_DataObject } return $this->_original; } + + /** + * Magic function called at serialize() time. + * + * We use this to drop a couple process-specific references + * from DB_DataObject which can cause trouble in future + * processes. + * + * @return array of variable names to include in serialization. + */ + + function __sleep() + { + $vars = parent::__sleep(); + $skip = array('_original', '_profile'); + return array_diff($vars, $skip); + } + } diff --git a/classes/Profile.php b/classes/Profile.php index 16484fbe6e..2638f745f7 100644 --- a/classes/Profile.php +++ b/classes/Profile.php @@ -1353,4 +1353,21 @@ class Profile extends Memcached_DataObject } return $profile; } + + /** + * Magic function called at serialize() time. + * + * We use this to drop a couple process-specific references + * from DB_DataObject which can cause trouble in future + * processes. + * + * @return array of variable names to include in serialization. + */ + + function __sleep() + { + $vars = parent::__sleep(); + $skip = array('_user'); + return array_diff($vars, $skip); + } } diff --git a/classes/User.php b/classes/User.php index d8f813c765..8642c78c27 100644 --- a/classes/User.php +++ b/classes/User.php @@ -983,4 +983,21 @@ class User extends Memcached_DataObject return $apps; } + + /** + * Magic function called at serialize() time. + * + * We use this to drop a couple process-specific references + * from DB_DataObject which can cause trouble in future + * processes. + * + * @return array of variable names to include in serialization. + */ + + function __sleep() + { + $vars = parent::__sleep(); + $skip = array('_profile'); + return array_diff($vars, $skip); + } } -- 2.39.5