From 4ac5c6262ab0c70521b241e74ecace6d74643b0c Mon Sep 17 00:00:00 2001 From: Chuck Hagenbuch Date: Sun, 23 Aug 2009 22:06:02 -0400 Subject: [PATCH] use a static class var for the cached instance, and make the method protected so that subclasses can access it if appropriate --- framework/Auth/lib/Horde/Auth.php | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/framework/Auth/lib/Horde/Auth.php b/framework/Auth/lib/Horde/Auth.php index 5e3a567a1..62dda895f 100644 --- a/framework/Auth/lib/Horde/Auth.php +++ b/framework/Auth/lib/Horde/Auth.php @@ -84,6 +84,13 @@ class Horde_Auth static protected $_instances = array(); /** + * Cached Horde_Browser instance + * + * @var Horde_Browser + */ + static protected $_browser = null; + + /** * The logout reason information. * * @var array @@ -401,7 +408,7 @@ class Horde_Auth } if (!empty($GLOBALS['conf']['auth']['checkbrowser'])) { - if ($_SESSION['horde_auth']['browser'] != self::_browser()->getAgentString()) { + if ($_SESSION['horde_auth']['browser'] != self::_getBrowser()->getAgentString()) { self::setAuthError(self::REASON_BROWSER); return false; } @@ -657,7 +664,7 @@ class Horde_Auth $_SESSION['horde_auth'] = array( 'app' => $app_array, - 'browser' => self::_browser()->getAgentString(), + 'browser' => self::_getBrowser()->getAgentString(), 'change' => !empty($options['change']), 'credentials' => Horde_Secret::write(Horde_Secret::getKey('auth'), serialize($credentials)), 'driver' => $GLOBALS['conf']['auth']['driver'], @@ -946,13 +953,12 @@ class Horde_Auth * * @return Horde_Browser A Horde_Browser instance. */ - static private function _browser() + static protected function _getBrowser() { - static $browser; - if (!isset($browser)) { - $browser = new Horde_Browser(); + if (!self::$_browser) { + self::$_browser = new Horde_Browser(); } - return $browser; + return self::$_browser; } /** -- 2.11.0