From: Michael M Slusarz Date: Wed, 14 Apr 2010 10:10:58 +0000 (-0600) Subject: Remove Horde_SessionObjects::singleton() X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=326e7ce0d176377f1a94f4db11d7e3a6139109af;p=horde.git Remove Horde_SessionObjects::singleton() --- diff --git a/framework/Core/lib/Horde/Core/Factory/KolabSession.php b/framework/Core/lib/Horde/Core/Factory/KolabSession.php index 5087ea39f..c6e2d77a7 100644 --- a/framework/Core/lib/Horde/Core/Factory/KolabSession.php +++ b/framework/Core/lib/Horde/Core/Factory/KolabSession.php @@ -109,7 +109,7 @@ class Horde_Core_Factory_KolabSession public function getStorage() { $storage = new Horde_Kolab_Session_Storage_Sessionobjects( - Horde_SessionObjects::singleton() + new Horde_SessionObjects() ); return $storage; } diff --git a/framework/Group/Group.php b/framework/Group/Group.php index 55ccec9cc..2d7dd3439 100644 --- a/framework/Group/Group.php +++ b/framework/Group/Group.php @@ -603,7 +603,7 @@ class Group { */ function shutdown() { - $session = Horde_SessionObjects::singleton(); + $session = new Horde_SessionObjects(); $session->overwrite('horde_group', $this, false); } @@ -679,7 +679,7 @@ class Group { $group = null; if (!empty($GLOBALS['conf']['group']['cache'])) { - $session = Horde_SessionObjects::singleton(); + $session = new Horde_SessionObjects(); $group = $session->query('horde_group'); } diff --git a/framework/SessionObjects/lib/Horde/SessionObjects.php b/framework/SessionObjects/lib/Horde/SessionObjects.php index 3e8149ee7..450f06d9a 100644 --- a/framework/SessionObjects/lib/Horde/SessionObjects.php +++ b/framework/SessionObjects/lib/Horde/SessionObjects.php @@ -16,13 +16,6 @@ class Horde_SessionObjects { /** - * The singleton instance. - * - * @var array - */ - static protected $_instance = array(); - - /** * The name of the store. * * @var string @@ -51,37 +44,16 @@ class Horde_SessionObjects protected $_sdata = null; /** - * Returns a reference to the global Horde_SessionObjects object, only - * creating it if it doesn't already exist. - * - * This method must be invoked as: - * $objectstore = Horde_SessionObjects::singleton(); - * - * @return Horde_SessionObjects The Horde_SessionObjects instance. - */ - static public function singleton($params = array()) - { - ksort($params); - $sig = md5(Horde_Serialize::serialize($params, Horde_Serialize::BASIC)); - - if (!isset(self::$_instance[$sig])) { - self::$_instance[$sig] = new self($params); - } - - return self::$_instance[$sig]; - } - - /** * Constructor. * - * @param array $params The parameter array. + * @param array $params Optional parameters: *
-     * Optional Parameters:
-     * 'name'  --  The name of the session variable to store the objects in.
-     * 'size'  --  The maximum size of the (non-prunable) object store.
+     * 'name' - (string) The name of the session variable to store the objects
+     *          in.
+     * 'size' - (integer) The maximum size of the (non-prunable) object store.
      * 
*/ - protected function __construct($params = array()) + public function __construct($params = array()) { if (isset($params['name'])) { $this->_name = $params['name']; diff --git a/framework/SessionObjects/package.xml b/framework/SessionObjects/package.xml index 008a4ecaf..ff28b228c 100644 --- a/framework/SessionObjects/package.xml +++ b/framework/SessionObjects/package.xml @@ -26,7 +26,8 @@ http://pear.php.net/dtd/package-2.0.xsd"> beta LGPL - * Added prune() function. + * Remove singleton(). + * Added prune() function. * Initial Horde 4 package diff --git a/framework/Share/Share.php b/framework/Share/Share.php index fe679658b..8d058fc2a 100644 --- a/framework/Share/Share.php +++ b/framework/Share/Share.php @@ -99,8 +99,7 @@ class Horde_Share { $signature = $app . '_' . $driver; if (!isset($shares[$signature]) && !empty($GLOBALS['conf']['share']['cache'])) { - require_once 'Horde/SessionObjects.php'; - $session = Horde_SessionObjects::singleton(); + $session = new Horde_SessionObjects(); $shares[$signature] = $session->query('horde_share_' . $app . '_' . $driver . '1'); } @@ -162,8 +161,7 @@ class Horde_Share { function shutdown() { $driver = str_replace('horde_share_', '', Horde_String::lower(get_class($this))); - require_once 'Horde/SessionObjects.php'; - $session = Horde_SessionObjects::singleton(); + $session = new Horde_SessionObjects(); $session->overwrite('horde_share_' . $this->_app . '_' . $driver, $this, false); } diff --git a/imp/lib/Compose.php b/imp/lib/Compose.php index 0306de8dd..a589804a4 100644 --- a/imp/lib/Compose.php +++ b/imp/lib/Compose.php @@ -99,7 +99,7 @@ class IMP_Compose static public function singleton($cacheid = null) { if (!empty($cacheid) && !isset(self::$_instances[$cacheid])) { - $obs = Horde_SessionObjects::singleton(); + $obs = $GLOBALS['injector']->getInstance('Horde_SessionObjects'); self::$_instances[$cacheid] = $obs->query($cacheid); } @@ -138,7 +138,7 @@ class IMP_Compose { if ($this->_modified) { $this->_modified = false; - $obs = Horde_SessionObjects::singleton(); + $obs = $GLOBALS['injector']->getInstance('Horde_SessionObjects'); $obs->overwrite($this->_cacheid, $this, false); } } @@ -176,7 +176,7 @@ class IMP_Compose } $this->deleteAllAttachments(); - $obs = Horde_SessionObjects::singleton(); + $obs = $GLOBALS['injector']->getInstance('Horde_SessionObjects'); $obs->prune($this->_cacheid); } diff --git a/imp/lib/Crypt/Pgp.php b/imp/lib/Crypt/Pgp.php index 1d77a3110..14c95a08a 100644 --- a/imp/lib/Crypt/Pgp.php +++ b/imp/lib/Crypt/Pgp.php @@ -665,7 +665,7 @@ class IMP_Crypt_Pgp extends Horde_Crypt_Pgp */ public function reloadWindow($reload) { - $cacheSess = Horde_SessionObjects::singleton(); + $cacheSess = $GLOBALS['injector']->getInstance('Horde_SessionObjects'); $href = $cacheSess->query($reload); $cacheSess->prune($reload); echo Horde::wrapInlineScript(array( diff --git a/imp/lib/Crypt/Smime.php b/imp/lib/Crypt/Smime.php index da172d76a..c21863363 100644 --- a/imp/lib/Crypt/Smime.php +++ b/imp/lib/Crypt/Smime.php @@ -502,7 +502,7 @@ class IMP_Crypt_Smime extends Horde_Crypt_Smime */ public function reloadWindow($reload) { - $cacheSess = Horde_SessionObjects::singleton(); + $cacheSess = $GLOBALS['injector']->getInstance('Horde_SessionObjects'); $href = $cacheSess->query($reload); $cacheSess->prune($reload); echo Horde::wrapInlineScript(array( diff --git a/imp/lib/Prefs/Ui.php b/imp/lib/Prefs/Ui.php index c4455d61b..fd4e442e2 100644 --- a/imp/lib/Prefs/Ui.php +++ b/imp/lib/Prefs/Ui.php @@ -1005,7 +1005,7 @@ class IMP_Prefs_Ui $t->set('keygen', addslashes(_("Key generation may take a long time to complete. Continue with key generation?"))); if ($_SESSION['imp']['file_upload']) { - $cacheSess = Horde_SessionObjects::singleton(); + $cacheSess = $GLOBALS['injector']->getInstance('Horde_SessionObjects'); $t->set('import_url', Horde::popupJs($pgp_url, array('params' => array('actionID' => 'import_personal_public_key', 'reload' => $cacheSess->storeOid($ui->selfUrl()->setRaw(true), false)), 'height' => 275, 'width' => 750, 'urlencode' => true))); } @@ -1105,7 +1105,7 @@ class IMP_Prefs_Ui if ($_SESSION['imp']['file_upload']) { $t->set('no_source', !$GLOBALS['prefs']->getValue('add_source')); if (!$t->get('no_source')) { - $cacheSess = Horde_SessionObjects::singleton(); + $cacheSess = $GLOBALS['injector']->getInstance('Horde_SessionObjects'); $t->set('import_url', Horde::popupJs($pgp_url, array('params' => array('actionID' => 'import_public_key', 'reload' => $cacheSess->storeOid($ui->selfUrl()->setRaw(true), false)), 'height' => 275, 'width' => 750, 'urlencode' => true))); $t->set('import_pubkey-help', Horde_Help::link('imp', 'pgp-import-pubkey')); } @@ -1240,7 +1240,7 @@ class IMP_Prefs_Ui $t->set('deletekeypair', addslashes(_("Are you sure you want to delete your keypair? (This is NOT recommended!)"))); $t->set('personalkey-delete-help', Horde_Help::link('imp', 'smime-delete-personal-certs')); } elseif ($_SESSION['imp']['file_upload']) { - $cacheSess = Horde_SessionObjects::singleton(); + $cacheSess = $GLOBALS['injector']->getInstance('Horde_SessionObjects'); $t->set('import_url', Horde::popupJs($smime_url, array('params' => array('actionID' => 'import_personal_public_key', 'reload' => $cacheSess->storeOid($ui->selfUrl()->setRaw(true), false)), 'height' => 275, 'width' => 750, 'urlencode' => true))); $t->set('import-cert-help', Horde_Help::link('imp', 'smime-import-personal-certs')); } @@ -1311,7 +1311,7 @@ class IMP_Prefs_Ui if ($_SESSION['imp']['file_upload']) { $t->set('no_source', !$GLOBALS['prefs']->getValue('add_source')); if (!$t->get('no_source')) { - $cacheSess = Horde_SessionObjects::singleton(); + $cacheSess = $GLOBALS['injector']->getInstance('Horde_SessionObjects'); $t->set('import_url', Horde::popupJs($smime_url, array('params' => array('actionID' => 'import_public_key', 'reload' => $cacheSess->storeOid($ui->selfUrl()->setRaw(true), false)), 'height' => 275, 'width' => 750, 'urlencode' => true))); $t->set('import_pubkey-help', Horde_Help::link('imp', 'smime-import-pubkey')); } diff --git a/ingo/lib/Storage.php b/ingo/lib/Storage.php index 599085a23..825df83ef 100644 --- a/ingo/lib/Storage.php +++ b/ingo/lib/Storage.php @@ -108,7 +108,7 @@ class Ingo_Storage */ public function shutdown() { - $cache = Horde_SessionObjects::singleton(); + $cache = $GLOBALS['injector']->getInstance('Horde_SessionObjects'); /* Store the current objects. */ foreach ($this->_cache as $key => $val) { @@ -140,7 +140,7 @@ class Ingo_Storage if (!isset($this->_cache[$field])) { $this->_cache[$field] = array('mod' => false); if (isset($_SESSION['ingo']['storage'][$field])) { - $cacheSess = Horde_SessionObjects::singleton(); + $cacheSess = $GLOBALS['injector']->getInstance('Horde_SessionObjects'); $this->_cache[$field]['ob'] = $cacheSess->query($_SESSION['ingo']['storage'][$field]); } else { $this->_cache[$field]['ob'] = $this->_retrieve($field, $readonly);