[icinga-checkins] icinga.org: icinga-web/mfrosch/1.8.2: Fix session handling for creation and destruction

git at icinga.org git at icinga.org
Mon Feb 11 16:13:49 CET 2013


Module: icinga-web
Branch: mfrosch/1.8.2
Commit: 2b164cd62b2bb98d8507c0a3c1043a9578ae9abc
URL:    https://git.icinga.org/?p=icinga-web.git;a=commit;h=2b164cd62b2bb98d8507c0a3c1043a9578ae9abc

Author: Markus Frosch <markus at lazyfrosch.de>
Date:   Wed Feb  6 21:36:14 2013 +0100

Fix session handling for creation and destruction

on creation the session gets immediatly written
into the database before any parallel running thread
might insert it as well
(without this the session will only be written into
the database when actual data is put in)

on destruction the session will now not really be
wiped from the database, but all data will be cleared
from it

(refs #3530)

---

 .../storage/AppKitDoctrineSessionStorage.class.php |   23 +++++++++++++-------
 1 files changed, 15 insertions(+), 8 deletions(-)

diff --git a/app/modules/AppKit/lib/storage/AppKitDoctrineSessionStorage.class.php b/app/modules/AppKit/lib/storage/AppKitDoctrineSessionStorage.class.php
index d9b7027..4b2a8fa 100755
--- a/app/modules/AppKit/lib/storage/AppKitDoctrineSessionStorage.class.php
+++ b/app/modules/AppKit/lib/storage/AppKitDoctrineSessionStorage.class.php
@@ -63,16 +63,19 @@ class AppKitDoctrineSessionStorage extends AgaviSessionStorage {
      */
     public function sessionDestroy($id) {
 
-        $result = AppKitDoctrineUtil::createQuery()
-                  ->delete('NsmSession')
-                  ->andWhere('session_name=? and session_id=?', array($this->getParameter('session_name'), $id))
-                  ->execute();
+        AppKitLogger::verbose("Destroying session (%s)", $id);
 
-        if ($result > 0) {
-            return true;
-        }
+        // loading the session and clearing its data
+        // please be aware, we are not really deleting the session
+        // from the database, but emptying its data
+        // this helps with proper session handling on logon
 
-        return false;
+        $this->sessionRead($id);
+
+        $data = '';
+        $this->sessionWrite($id, $data);
+
+        return true;
 
     }
 
@@ -135,6 +138,10 @@ class AppKitDoctrineSessionStorage extends AgaviSessionStorage {
             $this->NsmSession->session_id = $id;
             $this->NsmSession->session_name = $session_name;
 
+            // Immediately saving it empty
+            $data = '';
+            $this->sessionWrite($id, $data);
+
             return '';
         } else {
             AppKitLogger::verbose("Session found in database, reading data");





More information about the icinga-checkins mailing list