use a static class var for the cached instance, and make the method protected so...
authorChuck Hagenbuch <chuck@horde.org>
Mon, 24 Aug 2009 02:06:02 +0000 (22:06 -0400)
committerChuck Hagenbuch <chuck@horde.org>
Mon, 24 Aug 2009 02:06:02 +0000 (22:06 -0400)
framework/Auth/lib/Horde/Auth.php

index 5e3a567..62dda89 100644 (file)
@@ -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;
     }
 
     /**