From 8d3732276619ce6e2e18deaf304ad45da75814c5 Mon Sep 17 00:00:00 2001 From: Jan Schneider Date: Sun, 23 Aug 2009 15:40:30 +0200 Subject: [PATCH] Cache browser object, don't use singleton(). --- framework/Auth/lib/Horde/Auth.php | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/framework/Auth/lib/Horde/Auth.php b/framework/Auth/lib/Horde/Auth.php index 3cfc81bef..c43c1ddb8 100644 --- a/framework/Auth/lib/Horde/Auth.php +++ b/framework/Auth/lib/Horde/Auth.php @@ -401,8 +401,7 @@ class Horde_Auth } if (!empty($GLOBALS['conf']['auth']['checkbrowser'])) { - $browser = Horde_Browser::singleton(); - if ($_SESSION['horde_auth']['browser'] != $browser->getAgentString()) { + if ($_SESSION['horde_auth']['browser'] != self::_browser()->getAgentString()) { self::setAuthError(self::REASON_BROWSER); return false; } @@ -656,11 +655,9 @@ class Horde_Auth /* Clear any existing info. */ self::clearAuth(); - $browser = Horde_Browser::singleton(); - $_SESSION['horde_auth'] = array( 'app' => $app_array, - 'browser' => $browser->getAgentString(), + 'browser' => self::_browser()->getAgentString(), 'change' => !empty($options['change']), 'credentials' => Horde_Secret::write(Horde_Secret::getKey('auth'), serialize($credentials)), 'driver' => $GLOBALS['conf']['auth']['driver'], @@ -945,6 +942,20 @@ class Horde_Auth } /** + * Returns a cached Horde_Brower instance. + * + * @return Horde_Browser A Horde_Browser instance. + */ + static private function _browser() + { + static $browser; + if (!isset($browser)) { + $browser = new Horde_Browser(); + } + return $browser; + } + + /** * Converts to allowed 64 characters for APRMD5 passwords. * * @param string $value TODO -- 2.11.0