Revision: 3358
Author:   jaim...@gmail.com
Date:     Wed Feb  5 13:42:26 2014 UTC
Log: Solve the problem in issue #594 in a backwards compatible way that doesn't break anything.
http://code.google.com/p/simplesamlphp/source/detail?r=3358

Modified:
 /trunk/lib/SimpleSAML/Session.php

=======================================
--- /trunk/lib/SimpleSAML/Session.php   Wed Feb  5 13:42:18 2014 UTC
+++ /trunk/lib/SimpleSAML/Session.php   Wed Feb  5 13:42:26 2014 UTC
@@ -177,7 +177,6 @@
                $this->trackid = substr(md5(uniqid(rand(), true)), 0, 10);

                $this->dirty = TRUE;
-               $this->addShutdownFunction();

                /* Initialize data for session check function if defined */
                $globalConfig = SimpleSAML_Configuration::getInstance();
@@ -187,6 +186,32 @@
                        call_user_func($checkFunction, $this, TRUE);
                }
        }
+
+
+    /**
+ * Destructor for this class. It will save the session to the session handler
+     * in case the session has been marked as dirty. Do nothing otherwise.
+     */
+    public function __destruct() {
+        if(!$this->dirty) {
+            /* Session hasn't changed - don't bother saving it. */
+            return;
+        }
+
+        $this->dirty = FALSE;
+
+        $sh = SimpleSAML_SessionHandler::getSessionHandler();
+
+        try {
+            $sh->saveSession($this);
+        } catch (Exception $e) {
+            if (!($e instanceof SimpleSAML_Error_Exception)) {
+                $e = new SimpleSAML_Error_UnserializableException($e);
+            }
+            SimpleSAML_Logger::error('Unable to save session.');
+            $e->logError();
+        }
+    }


        /**
@@ -247,7 +272,6 @@
         * This function is called after this class has been deserialized.
         */
        public function __wakeup() {
-               $this->addShutdownFunction();

                /* TODO: Remove for version 1.8. */
                if ($this->authData === NULL) {
@@ -1164,42 +1188,6 @@

                return $session;
        }
-
-
-       /**
-        * Save the session to the session handler.
-        *
- * This function will check the dirty-flag to check if the session has changed.
-        */
-       public function saveSession() {
-
-               if(!$this->dirty) {
-                       /* Session hasn't changed - don't bother saving it. */
-                       return;
-               }
-
-               $this->dirty = FALSE;
-
-               $sh = SimpleSAML_SessionHandler::getSessionHandler();
-
-               try {
-                       $sh->saveSession($this);
-               } catch (Exception $e) {
-                       if (!($e instanceof SimpleSAML_Error_Exception)) {
-                               $e = new 
SimpleSAML_Error_UnserializableException($e);
-                       }
-                       SimpleSAML_Logger::error('Unable to save session.');
-                       $e->logError();
-               }
-       }
-
-
-       /**
-        * Add a shutdown function for saving this session object on exit.
-        */
-       private function addShutdownFunction() {
-               register_shutdown_function(array($this, 'saveSession'));
-       }


        /**

--
You received this message because you are subscribed to the Google Groups 
"simpleSAMLphp commits" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to simplesamlphp-commits+unsubscr...@googlegroups.com.
To post to this group, send email to simplesamlphp-commits@googlegroups.com.
Visit this group at http://groups.google.com/group/simplesamlphp-commits.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to