Fixed updating of virtual sessions and added removal of expired ones
authorAlexander Ebert <ebert@woltlab.com>
Sat, 19 Apr 2014 20:14:41 +0000 (22:14 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Sat, 19 Apr 2014 20:14:41 +0000 (22:14 +0200)
wcfsetup/install/files/lib/data/session/virtual/SessionVirtualEditor.class.php
wcfsetup/install/files/lib/system/cronjob/SessionCleanUpCronjob.class.php
wcfsetup/install/files/lib/system/session/SessionHandler.class.php

index 4c9e90983577e8f9c08cdfe8aa2251182dec79b3..3445bc44f3d387e4b43955c6df882e72c0b33712 100644 (file)
@@ -1,6 +1,7 @@
 <?php
 namespace wcf\data\session\virtual;
 use wcf\data\DatabaseObjectEditor;
+use wcf\system\WCF;
 
 /**
  * Provides functions to edit virtual sessions.
@@ -26,4 +27,16 @@ class SessionVirtualEditor extends DatabaseObjectEditor {
                        'lastActivityTime' => TIME_NOW
                ));
        }
+       
+       /**
+        * Deletes the expired virtual sessions.
+        * 
+        * @param       integer         $timestamp
+        */
+       public static function deleteExpiredSessions($timestamp) {
+               $sql = "DELETE FROM     ".call_user_func(array(static::$baseClass, 'getDatabaseTableName'))."
+                       WHERE           lastActivityTime < ?";
+               $statement = WCF::getDB()->prepareStatement($sql);
+               $statement->execute(array($timestamp));
+       }
 }
index 73d03012ffcc5aad6607f788ef302916dfa34432..d96fe1b222e653c0adb3af8b1f7c4dc2ce01fed8 100644 (file)
@@ -2,6 +2,7 @@
 namespace wcf\system\cronjob;
 use wcf\data\acp\session\ACPSessionEditor;
 use wcf\data\cronjob\Cronjob;
+use wcf\data\session\virtual\SessionVirtualEditor;
 use wcf\data\session\SessionEditor;
 
 /**
@@ -23,5 +24,6 @@ class SessionCleanUpCronjob extends AbstractCronjob {
                
                ACPSessionEditor::deleteExpiredSessions(TIME_NOW - SESSION_TIMEOUT);
                SessionEditor::deleteExpiredSessions(TIME_NOW - SESSION_TIMEOUT);
+               SessionVirtualEditor::deleteExpiredSessions(TIME_NOW - SESSION_TIMEOUT);
        }
 }
index 63285c3648147a1866c77a4c352023a5b8ff726d..670b2ad96e4c066121fe31a29947ac31b7bf3ecd 100644 (file)
@@ -342,7 +342,8 @@ class SessionHandler extends SingletonFactory {
                        $this->virtualSession = null;
                        if ($this->user->userID && $this->supportsVirtualSessions) {
                                $virtualSessionAction = new SessionVirtualAction(array(), 'create', array('data' => array('sessionID' => $this->session->sessionID)));
-                               $this->virtualSession = $virtualSessionAction->executeAction();
+                               $returnValues = $virtualSessionAction->executeAction();
+                               $this->virtualSession = $returnValues['returnValues'];
                        }
                }
        }