Hey folks,

SessionStorage::initialize's auto_start implementation causes a small problem when using an inheriting class (like PostgreSQLSessionStorage or my CreoleSessionStorage [http://veikkomakinen.com/agavi/source.php?file=SessionStorage.class.php&hidelineno=true]). If auto_start is explicitly set to true in config, SessionStorage goes ahead and starts the session before the inheriting class is finished with it's initialize method.

This can be fixed by setting auto_start parameter false in inheriting class before calling parent's initialize. Diff below shows this. This is just a quick and dirty solution. A better one would be solving the actual problem and separating initialize and auto-starting completely. This would require small changes in Context.class.php.


-veikko

P.S. PostgreSQL and MySQL storages also ignore auto_star=false. This too is fixed below.

-------------------------------------

$ svn diff
Index: PostgreSQLSessionStorage.class.php
===================================================================
--- PostgreSQLSessionStorage.class.php  (revision 255)
+++ PostgreSQLSessionStorage.class.php  (working copy)
@@ -71,12 +71,16 @@
        public function initialize ($context, $parameters = null)
        {

-               // disable auto_start
-               $this->setParameter('auto_start', false);
+               // disable auto_start to make sure parent doesn't start it
+ $auto_start = isset($parameters['auto_start']) ? $parameters['auto_start'] : true;
+               $parameters['auto_start'] = false;

                // initialize the parent
                parent::initialize($context, $parameters);

+               // reset auto_start
+               $this->setParameter('auto_start', $auto_start);
+
                if (!$this->hasParameter('db_table'))
                {

@@ -96,8 +100,10 @@
array($this, 'sessionDestroy'), array($this, 'sessionGC'));

-               // start our session
-               session_start();
+               if ($this->getParameter('auto_start', true)) {
+                       // start our session
+                       session_start();
+               }

        }

_______________________________________________
agavi-dev mailing list
[email protected]
http://labworkz.com/cgi-bin/mailman/listinfo/agavi-dev

Reply via email to