From: Chuck Hagenbuch Date: Thu, 15 Jan 2009 17:12:48 +0000 (-0500) Subject: cache -> cacheOb X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=80cf8cf4ae81d2462a02cbdc8558ea569b33c5db;p=horde.git cache -> cacheOb constructors protected for objects with singletons remove & --- diff --git a/imp/cache.php b/imp/cache.php index e29e0c328..e3700c29c 100644 --- a/imp/cache.php +++ b/imp/cache.php @@ -86,7 +86,7 @@ if (empty($cid)) { exit; } -if (!($cache = &IMP::getCacheOb())) { +if (!($cache = IMP::getCache())) { Horde::fatal('No cache backend available.', __FILE__, __LINE__); } diff --git a/imp/lib/Crypt/pgp.php b/imp/lib/Crypt/pgp.php index 11afe8999..52df2e390 100644 --- a/imp/lib/Crypt/pgp.php +++ b/imp/lib/Crypt/pgp.php @@ -164,7 +164,7 @@ class IMP_Horde_Crypt_pgp extends Horde_Crypt_pgp { /* If there is a cache driver configured, try to get the public key * from the cache. */ - if (($cache = &IMP::getCacheOb())) { + if (($cache = IMP::getCache())) { $result = $cache->get("PGPpublicKey_" . $address . $fingerprint, 3600); if ($result) { Horde::logMessage('PGPpublicKey: ' . serialize($result), __FILE__, __LINE__, PEAR_LOG_DEBUG); @@ -181,7 +181,7 @@ class IMP_Horde_Crypt_pgp extends Horde_Crypt_pgp /* See if the address points to the user's public key. */ if (is_a($result, 'PEAR_Error')) { require_once 'Horde/Identity.php'; - $identity = &Identity::singleton(array('imp', 'imp')); + $identity = Identity::singleton(array('imp', 'imp')); $personal_pubkey = $this->getPersonalPublicKey(); if (!empty($personal_pubkey) && $identity->hasAddress($address)) { $result = $personal_pubkey; diff --git a/imp/lib/Folder.php b/imp/lib/Folder.php index 13140fcb7..87f9776cb 100644 --- a/imp/lib/Folder.php +++ b/imp/lib/Folder.php @@ -37,13 +37,9 @@ class IMP_Folder * if it doesn't already exist. This ensures that only one IMP_Folder * instance is instantiated for any given session. * - * This method must be invoked as: - * $imp_folder = &IMP_Folder::singleton(); - * - * * @return IMP_Folder The IMP_Folder instance. */ - static public function &singleton() + static public function singleton() { static $folder; @@ -57,7 +53,7 @@ class IMP_Folder /** * Constructor. */ - function __construct() + protected function __construct() { if (!empty($GLOBALS['conf']['server']['cache_folders'])) { $this->_cacheid = 'imp_folder_cache|' . Auth::getAuth(); @@ -104,7 +100,7 @@ class IMP_Folder obtain it. */ $cache = null; if (is_null($this->_listCache)) { - if (!is_null($this->_cacheid) && ($cache = &IMP::getCacheOb())) { + if (!is_null($this->_cacheid) && ($cache = IMP::getCache())) { $ret = $cache->get($this->_cacheid, 3600); if (!empty($ret)) { $this->_listCache = unserialize($ret); @@ -120,7 +116,7 @@ class IMP_Folder return $this->_listCache[$sig]; } - $imaptree = &IMP_IMAP_Tree::singleton(); + $imaptree = IMP_IMAP_Tree::singleton(); $list_mask = IMP_IMAP_Tree::FLIST_CONTAINER | IMP_IMAP_Tree::FLIST_OB; if (!$sub) { @@ -161,7 +157,7 @@ class IMP_Folder */ public function clearFlistCache() { - if (!is_null($this->_cacheid) && ($cache = &IMP::getCacheOb())) { + if (!is_null($this->_cacheid) && ($cache = IMP::getCache())) { $cache->expire($this->_cacheid); } $this->_listCache = array(); @@ -201,7 +197,7 @@ class IMP_Folder if (!empty($deleted)) { /* Update the IMAP_Tree cache. */ - $imaptree = &IMP_IMAP_Tree::singleton(); + $imaptree = IMP_IMAP_Tree::singleton(); $imaptree->delete($deleted); $this->_onDelete($deleted); @@ -288,7 +284,7 @@ class IMP_Folder $this->clearFlistCache(); /* Update the IMAP_Tree object. */ - $imaptree = &IMP_IMAP_Tree::singleton(); + $imaptree = IMP_IMAP_Tree::singleton(); $imaptree->insert($folder); /* Recreate Virtual Folders. */ @@ -306,7 +302,7 @@ class IMP_Folder */ public function exists($folder) { - $imaptree = &IMP_IMAP_Tree::singleton(); + $imaptree = IMP_IMAP_Tree::singleton(); $elt = $imaptree->get($folder); if ($elt) { return !$imaptree->isContainer($elt); @@ -347,7 +343,7 @@ class IMP_Folder $deleted = array($old); $inserted = array($new); - $imaptree = &IMP_IMAP_Tree::singleton(); + $imaptree = IMP_IMAP_Tree::singleton(); /* Get list of any folders that are underneath this one. */ $all_folders = array_merge(array($old), $imaptree->folderList(IMP_IMAP_Tree::FLIST_UNSUB, $old)); @@ -409,7 +405,7 @@ class IMP_Folder if (!empty($subscribed)) { /* Initialize the IMAP_Tree object. */ - $imaptree = &IMP_IMAP_Tree::singleton(); + $imaptree = IMP_IMAP_Tree::singleton(); $imaptree->subscribe($subscribed); /* Reset the folder cache. */ @@ -455,7 +451,7 @@ class IMP_Folder if (!empty($unsubscribed)) { /* Initialize the IMAP_Tree object. */ - $imaptree = &IMP_IMAP_Tree::singleton(); + $imaptree = IMP_IMAP_Tree::singleton(); $imaptree->unsubscribe($unsubscribed); /* Reset the folder cache. */ diff --git a/imp/lib/IMAP/Tree.php b/imp/lib/IMAP/Tree.php index e18a83dff..c394b024a 100644 --- a/imp/lib/IMAP/Tree.php +++ b/imp/lib/IMAP/Tree.php @@ -192,19 +192,15 @@ class IMP_IMAP_Tree * that object. Else, create a new instance. Ensures that only one * instance is available at any time. * - * This method must be invoked as:
-     *   $imp_imap_tree = &IMP_IMAP_Tree::singleton();
-     * 
- * * @return IMP_IMAP_Tree The object or null. */ - static public function &singleton() + static public function singleton() { static $instance; if (!isset($instance)) { if (!empty($_SESSION['imp']['cache']['tree'])) { - $imp_cache = &IMP::getCacheOb(); + $imp_cache = IMP::getCache(); $instance = unserialize($imp_cache->get($_SESSION['imp']['cache']['tree'], 86400)); } if (empty($instance)) { @@ -218,7 +214,7 @@ class IMP_IMAP_Tree /** * Constructor. */ - function __construct() + protected function __construct() { if ($_SESSION['imp']['protocol'] == 'imap') { $ns = $GLOBALS['imp_imap']->getNamespaceList(); @@ -228,7 +224,7 @@ class IMP_IMAP_Tree } if (!isset($_SESSION['imp']['cache']['tree'])) { - $imp_cache = &IMP::getCacheOb(); + $imp_cache = IMP::getCache(); $_SESSION['imp']['cache']['tree'] = $imp_cache ? uniqid(mt_rand() . Auth::getAuth()) : null; @@ -281,7 +277,7 @@ class IMP_IMAP_Tree return; } - $imp_cache = &IMP::getCacheOb(); + $imp_cache = IMP::getCache(); $imp_cache->set($_SESSION['imp']['cache']['tree'], serialize($this), 86400); } @@ -1182,7 +1178,7 @@ class IMP_IMAP_Tree } if (!empty($id) && !$GLOBALS['prefs']->isLocked('nav_poll')) { - $imp_folder = &IMP_Folder::singleton(); + $imp_folder = IMP_Folder::singleton(); $this->getPollList(); foreach ($id as $val) { if (!$this->isSubscribed($this->_tree[$val])) { @@ -1738,7 +1734,7 @@ class IMP_IMAP_Tree /* Initialize the user's identities. */ require_once 'Horde/Identity.php'; - $identity = &Identity::singleton(array('imp', 'imp')); + $identity = Identity::singleton(array('imp', 'imp')); return array( 'trash' => IMP::folderPref($prefs->getValue('trash_folder'), true), diff --git a/imp/lib/IMP.php b/imp/lib/IMP.php index b096fa80a..b3553ba9b 100644 --- a/imp/lib/IMP.php +++ b/imp/lib/IMP.php @@ -1391,7 +1391,7 @@ class IMP break; } - $imp_imap = &$GLOBALS['imp_imap']->ob; + $imp_imap = $GLOBALS['imp_imap']->ob; $msg = sprintf( $status_msg . ' for %s [%s]%s to {%s:%s [%s]}', @@ -1502,7 +1502,7 @@ class IMP if (empty($cache_type) || $cache_type == 'none' || (($cache_type == 'horde_cache') && - !($cache = self::getCacheOb()))) { + !($cache = self::getCache()))) { Horde::includeScriptFiles(); return; } @@ -1660,7 +1660,7 @@ class IMP if (empty($cache_type) || $cache_type == 'none' || (($cache_type == 'horde_cache') && - !($cache = self::getCacheOb()))) { + !($cache = self::getCache()))) { $css_out = array_merge($css, $css_out); } else { $mtime = array(0); @@ -1956,7 +1956,7 @@ class IMP * * @return Horde_Cache A pointer to a Horde_Cache object. */ - public static function getCacheOb() + public static function getCache() { global $conf; diff --git a/imp/lib/Mailbox.php b/imp/lib/Mailbox.php index 229fedae2..957c27435 100644 --- a/imp/lib/Mailbox.php +++ b/imp/lib/Mailbox.php @@ -68,9 +68,6 @@ class IMP_Mailbox * It will only create a new instance if no IMP_Mailbox instance with * the same parameters currently exists. * - * This method must be invoked as: - * $var = &IMP_Mailbox::singleton($mailbox[, $index]); - * * @param string $mailbox See IMP_Mailbox constructor. * @param integer $index See IMP_Mailbox constructor. * @@ -165,7 +162,7 @@ class IMP_Mailbox $fetch_criteria[Horde_Imap_Client::FETCH_HEADERS] = array(array('headers' => $headers, 'label' => 'imp', 'parse' => true, 'peek' => true)); } - $cacheob = $preview ? $GLOBALS['imp_imap']->ob->getCacheOb() : null; + $cache = $preview ? $GLOBALS['imp_imap']->ob->getCache() : null; /* Retrieve information from each mailbox. */ foreach ($to_process as $mbox => $ids) { @@ -174,9 +171,9 @@ class IMP_Mailbox if ($preview) { $preview_info = $tostore = array(); - if ($cacheob) { + if ($cache) { try { - $preview_info = $cacheob->get($mbox, array_keys($ids), array('IMPpreview', 'IMPpreviewc')); + $preview_info = $cache->get($mbox, array_keys($ids), array('IMPpreview', 'IMPpreviewc')); } catch (Horde_Imap_Client_Exception $e) {} } } @@ -193,13 +190,13 @@ class IMP_Mailbox !$GLOBALS['prefs']->getValue('preview_show_unread') || !in_array('\\seen', $v['flags']))) { if (!isset($preview_info[$k])) { - $imp_contents = &IMP_Contents::singleton($k . IMP::IDX_SEP . $mbox); + $imp_contents = IMP_Contents::singleton($k . IMP::IDX_SEP . $mbox); if (is_a($imp_contents, 'PEAR_Error')) { $preview_info[$k] = array('IMPpreview' => '', 'IMPpreviewc' => false); } else { $prev = $imp_contents->generatePreview(); $preview_info[$k] = array('IMPpreview' => $prev['text'], 'IMPpreviewc' => $prev['cut']); - if (!is_null($cacheob)) { + if (!is_null($cache)) { $tostore[$k] = $preview_info[$k]; } } @@ -214,8 +211,8 @@ class IMP_Mailbox $uids[$mbox] = array_keys($fetch_res); - if (!is_null($cacheob) && !empty($tostore)) { - $cacheob->set($mbox, $tostore); + if (!is_null($cache) && !empty($tostore)) { + $cache->set($mbox, $tostore); } } catch (Horde_Imap_Client_Exception $e) {} } diff --git a/imp/lib/Template.php b/imp/lib/Template.php index 09b6dfbb0..109f227b9 100644 --- a/imp/lib/Template.php +++ b/imp/lib/Template.php @@ -110,7 +110,7 @@ class IMP_Template { } - $this->_cache = &IMP::getCacheOb(); + $this->_cache = IMP::getCache(); } /**