From 4ac2611e789b89e4cedb2139faadef1bcb6f204d Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Sat, 19 Apr 2014 22:14:41 +0200 Subject: [PATCH] Fixed updating of virtual sessions and added removal of expired ones --- .../session/virtual/SessionVirtualEditor.class.php | 13 +++++++++++++ .../system/cronjob/SessionCleanUpCronjob.class.php | 2 ++ .../lib/system/session/SessionHandler.class.php | 3 ++- 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/wcfsetup/install/files/lib/data/session/virtual/SessionVirtualEditor.class.php b/wcfsetup/install/files/lib/data/session/virtual/SessionVirtualEditor.class.php index 4c9e909835..3445bc44f3 100644 --- a/wcfsetup/install/files/lib/data/session/virtual/SessionVirtualEditor.class.php +++ b/wcfsetup/install/files/lib/data/session/virtual/SessionVirtualEditor.class.php @@ -1,6 +1,7 @@ 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)); + } } diff --git a/wcfsetup/install/files/lib/system/cronjob/SessionCleanUpCronjob.class.php b/wcfsetup/install/files/lib/system/cronjob/SessionCleanUpCronjob.class.php index 73d03012ff..d96fe1b222 100644 --- a/wcfsetup/install/files/lib/system/cronjob/SessionCleanUpCronjob.class.php +++ b/wcfsetup/install/files/lib/system/cronjob/SessionCleanUpCronjob.class.php @@ -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); } } diff --git a/wcfsetup/install/files/lib/system/session/SessionHandler.class.php b/wcfsetup/install/files/lib/system/session/SessionHandler.class.php index 63285c3648..670b2ad96e 100644 --- a/wcfsetup/install/files/lib/system/session/SessionHandler.class.php +++ b/wcfsetup/install/files/lib/system/session/SessionHandler.class.php @@ -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']; } } } -- 2.20.1