Bug #9315: Fix setting session_cache_limiter value
authorMichael M Slusarz <slusarz@curecanti.org>
Mon, 18 Oct 2010 21:27:33 +0000 (15:27 -0600)
committerMichael M Slusarz <slusarz@curecanti.org>
Tue, 19 Oct 2010 17:08:26 +0000 (11:08 -0600)
framework/Core/lib/Horde/Registry.php
framework/Core/lib/Horde/Session.php

index 85050a0..e61dabe 100644 (file)
@@ -184,7 +184,7 @@ class Horde_Registry
             // Chicken/egg: Browser object doesn't exist yet.
             $browser = new Horde_Core_Browser();
             if ($browser->isBrowser('mozilla')) {
-                session_cache_limiter('private, must-revalidate');
+                $args['session_cache_limiter'] = 'private, must-revalidate';
             }
             break;
 
@@ -198,7 +198,7 @@ class Horde_Registry
         }
 
         $classname = __CLASS__;
-        $registry = $GLOBALS['registry'] = new $classname($s_ctrl);
+        $registry = $GLOBALS['registry'] = new $classname($s_ctrl, $args['session_cache_limiter']);
         $registry->initialApp = $app;
 
         $appob = $registry->getApiInstance($app, 'application');
@@ -244,10 +244,11 @@ class Horde_Registry
      * Create a new Horde_Registry instance.
      *
      * @param integer $session_flags  Any session flags.
+     * @param string $cache_limiter   The cache limiter to use.
      *
      * @throws Horde_Exception
      */
-    public function __construct($session_flags = 0)
+    protected function __construct($session_flags, $cache_limiter)
     {
         /* Define autoloader callbacks. */
         $callbacks = array(
@@ -368,15 +369,16 @@ class Horde_Registry
         }
 
         /* Start a session. */
+        $GLOBALS['session'] = $session = new Horde_Session();
         if ($session_flags & self::SESSION_NONE ||
             (PHP_SAPI == 'cli') ||
             (((PHP_SAPI == 'cgi') || (PHP_SAPI == 'cgi-fcgi')) &&
              empty($_SERVER['SERVER_NAME']))) {
             /* Never start a session if the session flags include
                SESSION_NONE. */
-            $GLOBALS['session'] = $session = new Horde_Session(false);
+            $session->setup(false, $cache_limiter);
         } else {
-            $GLOBALS['session'] = $session = new Horde_Session();
+            $session->setup(true, $cache_limiter);
             if ($session_flags & self::SESSION_READONLY) {
                 /* Close the session immediately so no changes can be made but
                    values are still available. */
index a01f5e6..989ff06 100644 (file)
@@ -52,26 +52,24 @@ class Horde_Session implements ArrayAccess
 
     /**
      * Constructor.
-     *
-     * @param boolean $start  Initiate the session?
      */
-    public function __construct($start = true)
+    public function __construct()
     {
         $this->_lzf = Horde_Util::extensionExists('lzf');
-
-        $this->setup($start);
     }
 
     /**
      * Sets a custom session handler up, if there is one.
      *
-     * @param boolean $start  Initiate the session?
+     * @param boolean $start         Initiate the session?
+     * @param string $cache_limiter  Override for the session cache limiter
+     *                               value.
      *
      * @throws Horde_Exception
      */
-    public function setup($start = true)
+    public function setup($start = true, $cache_limiter = null)
     {
-        global $conf, $registry;
+        global $conf;
 
         ini_set('url_rewriter.tags', 0);
         if (empty($conf['session']['use_only_cookies'])) {
@@ -90,7 +88,7 @@ class Horde_Session implements ArrayAccess
             $conf['cookie']['domain'],
             $conf['use_ssl'] == 1 ? 1 : 0
         );
-        session_cache_limiter(is_null($registry->initParams['session_cache_limiter']) ? $conf['session']['cache_limiter'] : $registry->initParams['session_cache_limiter']);
+        session_cache_limiter(is_null($cache_limiter) ? $conf['session']['cache_limiter'] : $cache_limiter);
         session_name(urlencode($conf['session']['name']));
 
         /* We want to create an instance here, not get, since we may be