Remove Horde_SessionObjects::singleton()
authorMichael M Slusarz <slusarz@curecanti.org>
Wed, 14 Apr 2010 10:10:58 +0000 (04:10 -0600)
committerMichael M Slusarz <slusarz@curecanti.org>
Wed, 14 Apr 2010 20:03:53 +0000 (14:03 -0600)
framework/Core/lib/Horde/Core/Factory/KolabSession.php
framework/Group/Group.php
framework/SessionObjects/lib/Horde/SessionObjects.php
framework/SessionObjects/package.xml
framework/Share/Share.php
imp/lib/Compose.php
imp/lib/Crypt/Pgp.php
imp/lib/Crypt/Smime.php
imp/lib/Prefs/Ui.php
ingo/lib/Storage.php

index 5087ea3..c6e2d77 100644 (file)
@@ -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;
     }
index 55ccec9..2d7dd34 100644 (file)
@@ -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');
         }
 
index 3e8149e..450f06d 100644 (file)
 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:
      * <pre>
-     * 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.
      * </pre>
      */
-    protected function __construct($params = array())
+    public function __construct($params = array())
     {
         if (isset($params['name'])) {
             $this->_name = $params['name'];
index 008a4ec..ff28b22 100644 (file)
@@ -26,7 +26,8 @@ http://pear.php.net/dtd/package-2.0.xsd">
   <api>beta</api>
  </stability>
  <license uri="http://www.gnu.org/copyleft/lesser.html">LGPL</license>
- <notes>* Added prune() function.
+ <notes>* Remove singleton().
+ * Added prune() function.
  * Initial Horde 4 package</notes>
  <contents>
   <dir name="/">
index fe67965..8d058fc 100644 (file)
@@ -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);
     }
 
index 0306de8..a589804 100644 (file)
@@ -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);
     }
 
index 1d77a31..14c95a0 100644 (file)
@@ -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(
index da172d7..c218633 100644 (file)
@@ -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(
index c4455d6..fd4e442 100644 (file)
@@ -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'));
             }
index 599085a..825df83 100644 (file)
@@ -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);