From: Michael M Slusarz Date: Thu, 8 Oct 2009 22:15:21 +0000 (-0600) Subject: Destructor fixes. X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=187a7e90d370dccd2cdeed3be439728080dc309c;p=horde.git Destructor fixes. Destructors have no access to the session - need to do these tasks in a function registered via register_shutdown_function(). --- diff --git a/imp/lib/Compose.php b/imp/lib/Compose.php index ae9e75965..9b442c3d4 100644 --- a/imp/lib/Compose.php +++ b/imp/lib/Compose.php @@ -119,13 +119,14 @@ class IMP_Compose protected function __construct($cacheid) { $this->_cacheid = $cacheid; + register_shutdown_function(array($this, 'shutdown')); } /** * Store a serialized version of ourself in the current session on * shutdown. */ - public function __destruct() + public function shutdown() { if ($this->_modified) { $this->_modified = false; diff --git a/imp/lib/Imap.php b/imp/lib/Imap.php index ba13826da..adda112c2 100644 --- a/imp/lib/Imap.php +++ b/imp/lib/Imap.php @@ -51,12 +51,14 @@ class IMP_Imap /* Rebuild the Horde_Imap_Client object. */ $this->_loadImapObject(); + + register_shutdown_function(array($this, 'shutdown')); } /** * Save the Horde_Imap_Client object on session shutdown. */ - public function __destruct() + public function shutdown() { /* Only need to serialize object once a session. When we do * serialize, make sure we login in order to ensure we have done the diff --git a/imp/lib/Imap/Tree.php b/imp/lib/Imap/Tree.php index 1703737ca..456a472cb 100644 --- a/imp/lib/Imap/Tree.php +++ b/imp/lib/Imap/Tree.php @@ -243,6 +243,7 @@ class IMP_Imap_Tree } $this->init(); + $this->__wakeup(); } /** @@ -255,9 +256,17 @@ class IMP_Imap_Tree } /** + * Tasks to do on wakeup. + */ + public function __wakeup() + { + register_shutdown_function(array($this, 'shutdown')); + } + + /** * Store a serialized version of ourself in the current session. */ - public function __destruct() + public function shutdown() { /* We only need to store the object if using Horde_Cache and the tree * has changed. */ diff --git a/imp/lib/Mailbox.php b/imp/lib/Mailbox.php index 2bbcdb6da..42ddcf9d9 100644 --- a/imp/lib/Mailbox.php +++ b/imp/lib/Mailbox.php @@ -107,6 +107,8 @@ class IMP_Mailbox } $this->setIndex($uid); } + + register_shutdown_function(array($this, 'shutdown')); } /** @@ -115,7 +117,7 @@ class IMP_Mailbox * list, and to ensure messages aren't marked as missing in search * mailboxes (e.g. if search is dependent on unseen flag). */ - public function __destruct() + public function shutdown() { if (!is_null($this->_arrayIndex)) { /* Casting $_sorted to integers saves a significant amount of diff --git a/ingo/lib/Storage.php b/ingo/lib/Storage.php index 0ffd7534c..995a7e2cc 100644 --- a/ingo/lib/Storage.php +++ b/ingo/lib/Storage.php @@ -96,9 +96,17 @@ class Ingo_Storage } /** - * Destructor. + * Constructor. */ - public function __destruct() + public function __construct() + { + register_shutdown_function(array($this, 'shutdown')); + } + + /** + * Shutdown function. + */ + public function shutdown() { $cache = Horde_SessionObjects::singleton(); diff --git a/ingo/lib/Storage/Prefs.php b/ingo/lib/Storage/Prefs.php index be3547edf..a6a63318f 100644 --- a/ingo/lib/Storage/Prefs.php +++ b/ingo/lib/Storage/Prefs.php @@ -20,6 +20,7 @@ class Ingo_Storage_Prefs extends Ingo_Storage public function __construct($params = array()) { $this->_params = $params; + parent::__construct(); } /** diff --git a/ingo/lib/Storage/Sql.php b/ingo/lib/Storage/Sql.php index 1800dbebd..07d68bf45 100644 --- a/ingo/lib/Storage/Sql.php +++ b/ingo/lib/Storage/Sql.php @@ -119,6 +119,8 @@ class Ingo_Storage_Sql extends Ingo_Storage /* Default to the same DB handle for the writer too. */ $this->_db =& $this->_write_db; } + + parent::__construct(); } /**