From 34c95e168ea32f282b213ae9e6677ced086f52ff Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tim=20D=C3=BCsterhus?= Date: Fri, 25 Mar 2016 20:58:33 +0100 Subject: [PATCH] Move sessionVariables into virtual session --- .../lib/system/session/SessionHandler.class.php | 13 ++++++++----- wcfsetup/setup/db/install.sql | 6 +++--- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/wcfsetup/install/files/lib/system/session/SessionHandler.class.php b/wcfsetup/install/files/lib/system/session/SessionHandler.class.php index 6d5489d1be..6352dda2d1 100644 --- a/wcfsetup/install/files/lib/system/session/SessionHandler.class.php +++ b/wcfsetup/install/files/lib/system/session/SessionHandler.class.php @@ -386,7 +386,7 @@ class SessionHandler extends SingletonFactory { * Initializes session variables. */ protected function loadVariables() { - @$this->variables = unserialize($this->session->sessionVariables); + @$this->variables = unserialize($this->virtualSession->sessionVariables); if (!is_array($this->variables)) { $this->variables = array(); } @@ -839,7 +839,7 @@ class SessionHandler extends SingletonFactory { $this->session = $session; // inherit security token - $variables = @unserialize($this->session->sessionVariables); + $variables = @unserialize($this->virtualSession->sessionVariables); if (is_array($variables) && !empty($variables['__SECURITY_TOKEN'])) { $this->register('__SECURITY_TOKEN', $variables['__SECURITY_TOKEN']); } @@ -873,9 +873,6 @@ class SessionHandler extends SingletonFactory { $data['objectType'] = RequestHandler::getInstance()->getActiveRequest()->getRequestObject()->getObjectType(); $data['objectID'] = RequestHandler::getInstance()->getActiveRequest()->getRequestObject()->getObjectID(); } - if ($this->variablesChanged) { - $data['sessionVariables'] = serialize($this->variables); - } // update session /** @var \wcf\data\DatabaseObjectEditor $sessionEditor */ @@ -890,6 +887,12 @@ class SessionHandler extends SingletonFactory { $virtualSessionEditor = new SessionVirtualEditor($this->virtualSession); } $virtualSessionEditor->updateLastActivityTime(); + + $data = []; + if ($this->variablesChanged) { + $data['sessionVariables'] = serialize($this->variables); + } + $virtualSessionEditor->update($data); } } diff --git a/wcfsetup/setup/db/install.sql b/wcfsetup/setup/db/install.sql index 383938ae78..9339d25f8d 100644 --- a/wcfsetup/setup/db/install.sql +++ b/wcfsetup/setup/db/install.sql @@ -74,8 +74,7 @@ CREATE TABLE wcf1_acp_session ( parentObjectType VARCHAR(255) NOT NULL DEFAULT '', parentObjectID INT(10) NOT NULL DEFAULT 0, objectType VARCHAR(255) NOT NULL DEFAULT '', - objectID INT(10) NOT NULL DEFAULT 0, - sessionVariables MEDIUMTEXT + objectID INT(10) NOT NULL DEFAULT 0 ); DROP TABLE IF EXISTS wcf1_acp_session_access_log; @@ -110,6 +109,7 @@ CREATE TABLE wcf1_acp_session_virtual ( ipAddress VARCHAR(39) NOT NULL DEFAULT '', userAgent VARCHAR(255) NOT NULL DEFAULT '', lastActivityTime INT(10) NOT NULL DEFAULT 0, + sessionVariables MEDIUMTEXT, UNIQUE KEY (sessionID, ipAddress, userAgent) ); @@ -1074,7 +1074,6 @@ CREATE TABLE wcf1_session ( parentObjectID INT(10) NOT NULL DEFAULT 0, objectType VARCHAR(255) NOT NULL DEFAULT '', objectID INT(10) NOT NULL DEFAULT 0, - sessionVariables MEDIUMTEXT, spiderID INT(10), KEY packageID (lastActivityTime, spiderID), UNIQUE KEY uniqueUserID (userID) @@ -1087,6 +1086,7 @@ CREATE TABLE wcf1_session_virtual ( ipAddress VARCHAR(39) NOT NULL DEFAULT '', userAgent VARCHAR(255) NOT NULL DEFAULT '', lastActivityTime INT(10) NOT NULL DEFAULT 0, + sessionVariables MEDIUMTEXT, UNIQUE KEY (sessionID, ipAddress, userAgent) ); -- 2.20.1