From 5c4282aa5342800d2002d14dbcb7ef9ea1f1f99d Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Thu, 24 Nov 2016 18:51:27 +0100 Subject: [PATCH] Moved `sessionVariables` back --- com.woltlab.wcf/update_1.sql | 1 - com.woltlab.wcf/update_3.sql | 2 -- .../acp/update_com.woltlab.wcf_3.0_dropColumns.php | 2 +- .../acp/update_com.woltlab.wcf_3.0_pre_sql.php | 5 ++--- .../lib/data/acp/session/ACPSession.class.php | 1 + .../session/virtual/ACPSessionVirtual.class.php | 3 +-- .../lib/system/session/SessionHandler.class.php | 14 ++++++-------- wcfsetup/setup/db/install.sql | 4 ++-- 8 files changed, 13 insertions(+), 19 deletions(-) diff --git a/com.woltlab.wcf/update_1.sql b/com.woltlab.wcf/update_1.sql index abc6b00050..e09b2b897c 100644 --- a/com.woltlab.wcf/update_1.sql +++ b/com.woltlab.wcf/update_1.sql @@ -21,7 +21,6 @@ ALTER TABLE wcf1_acp_session DROP COLUMN parentObjectType; ALTER TABLE wcf1_acp_session DROP COLUMN parentObjectID; ALTER TABLE wcf1_acp_session DROP COLUMN objectType; ALTER TABLE wcf1_acp_session DROP COLUMN objectID; -ALTER TABLE wcf1_acp_session DROP COLUMN sessionVariables; ALTER TABLE wcf1_application DROP COLUMN cookiePath; ALTER TABLE wcf1_application DROP COLUMN isPrimary; diff --git a/com.woltlab.wcf/update_3.sql b/com.woltlab.wcf/update_3.sql index 9d98bf1a12..86df654678 100644 --- a/com.woltlab.wcf/update_3.sql +++ b/com.woltlab.wcf/update_3.sql @@ -5,8 +5,6 @@ ALTER TABLE wcf1_session ADD parentPageObjectID INT(10); ALTER TABLE wcf1_session ADD KEY pageID (pageID, pageObjectID); ALTER TABLE wcf1_session ADD KEY parentPageID (parentPageID, parentPageObjectID); -ALTER TABLE wcf1_session_virtual ADD sessionVariables MEDIUMTEXT; - DROP TABLE IF EXISTS wcf1_sitemap; ALTER TABLE wcf1_smiley ADD smileyPath2x VARCHAR(255) NOT NULL DEFAULT ''; diff --git a/wcfsetup/install/files/acp/update_com.woltlab.wcf_3.0_dropColumns.php b/wcfsetup/install/files/acp/update_com.woltlab.wcf_3.0_dropColumns.php index cac9ea3bd1..ae47579c2d 100644 --- a/wcfsetup/install/files/acp/update_com.woltlab.wcf_3.0_dropColumns.php +++ b/wcfsetup/install/files/acp/update_com.woltlab.wcf_3.0_dropColumns.php @@ -10,7 +10,7 @@ use wcf\util\StringUtil; * @package WoltLabSuite\Core */ $data = <<prepareStatement($sql); $statement->execute(); // create virtual session for current user -$sql = "INSERT INTO wcf".WCF_N."_acp_session_virtual (sessionID, ipAddress, userAgent, lastActivityTime, sessionVariables) SELECT sessionID, ipAddress, userAgent, lastActivityTime, sessionVariables FROM wcf".WCF_N."_acp_session WHERE sessionID = ?"; +$sql = "INSERT INTO wcf".WCF_N."_acp_session_virtual (sessionID, ipAddress, userAgent, lastActivityTime) SELECT sessionID, ipAddress, userAgent, lastActivityTime FROM wcf".WCF_N."_acp_session WHERE sessionID = ?"; $statement = \wcf\system\WCF::getDB()->prepareStatement($sql); $statement->execute([WCF::getSession()->sessionID]); diff --git a/wcfsetup/install/files/lib/data/acp/session/ACPSession.class.php b/wcfsetup/install/files/lib/data/acp/session/ACPSession.class.php index 6e865956b8..f072e463e0 100644 --- a/wcfsetup/install/files/lib/data/acp/session/ACPSession.class.php +++ b/wcfsetup/install/files/lib/data/acp/session/ACPSession.class.php @@ -18,6 +18,7 @@ use wcf\system\WCF; * @property-read integer $lastActivityTime timestamp at which the latest activity occured * @property-read string $requestURI uri of the latest request * @property-read string $requestMethod used request method of the latest request (`GET`, `POST`) + * @property-read string $sessionVariables serialized array with variables stored on a session-basis */ class ACPSession extends DatabaseObject { /** diff --git a/wcfsetup/install/files/lib/data/acp/session/virtual/ACPSessionVirtual.class.php b/wcfsetup/install/files/lib/data/acp/session/virtual/ACPSessionVirtual.class.php index 39d2c67acb..bb98a6c21c 100644 --- a/wcfsetup/install/files/lib/data/acp/session/virtual/ACPSessionVirtual.class.php +++ b/wcfsetup/install/files/lib/data/acp/session/virtual/ACPSessionVirtual.class.php @@ -22,8 +22,7 @@ use wcf\util\UserUtil; * @property-read string $sessionID id of the acp session the virtual acp session belongs to * @property-read string $ipAddress id of the user whom the virtual acp session belongs to * @property-read string $userAgent user agent of the user whom the virtual acp session belongs to - * @property-read integer $lastActivityTime timestamp at which the latest activity occured - * @property-read string $sessionVariables serialized array with variables stored on a session-basis + * @property-read integer $lastActivityTime timestamp at which the latest activity occurred */ class ACPSessionVirtual extends DatabaseObject { /** diff --git a/wcfsetup/install/files/lib/system/session/SessionHandler.class.php b/wcfsetup/install/files/lib/system/session/SessionHandler.class.php index 887a46c62e..1c536ad462 100644 --- a/wcfsetup/install/files/lib/system/session/SessionHandler.class.php +++ b/wcfsetup/install/files/lib/system/session/SessionHandler.class.php @@ -399,7 +399,7 @@ class SessionHandler extends SingletonFactory { * Initializes session variables. */ protected function loadVariables() { - @$this->variables = unserialize($this->virtualSession->sessionVariables); + @$this->variables = unserialize($this->session->sessionVariables); if (!is_array($this->variables)) { $this->variables = []; } @@ -848,7 +848,7 @@ class SessionHandler extends SingletonFactory { $this->session = $session; // inherit security token - $variables = @unserialize($this->virtualSession->sessionVariables); + $variables = @unserialize($this->session->sessionVariables); if (is_array($variables) && !empty($variables['__SECURITY_TOKEN'])) { $this->register('__SECURITY_TOKEN', $variables['__SECURITY_TOKEN']); } @@ -875,6 +875,9 @@ class SessionHandler extends SingletonFactory { 'requestMethod' => $this->requestMethod, 'lastActivityTime' => TIME_NOW ]; + if ($this->variablesChanged) { + $data['sessionVariables'] = serialize($this->variables); + } if (!class_exists('wcf\system\CLIWCF', false) && !$this->isACP && !$this->disableTracking) { $pageLocations = PageLocationManager::getInstance()->getLocations(); if (isset($pageLocations[0])) { @@ -905,13 +908,8 @@ class SessionHandler extends SingletonFactory { else { $virtualSessionEditor = new SessionVirtualEditor($this->virtualSession); } - $virtualSessionEditor->updateLastActivityTime(); - $data = []; - if ($this->variablesChanged) { - $data['sessionVariables'] = serialize($this->variables); - } - $virtualSessionEditor->update($data); + $virtualSessionEditor->updateLastActivityTime(); } } diff --git a/wcfsetup/setup/db/install.sql b/wcfsetup/setup/db/install.sql index eaa81f0f77..1a5494940f 100644 --- a/wcfsetup/setup/db/install.sql +++ b/wcfsetup/setup/db/install.sql @@ -110,6 +110,7 @@ CREATE TABLE wcf1_acp_session_log ( userAgent VARCHAR(255) NOT NULL DEFAULT '', time INT(10) NOT NULL DEFAULT 0, lastActivityTime INT(10) NOT NULL DEFAULT 0, + sessionVariables MEDIUMTEXT, KEY sessionID (sessionID) ); @@ -120,7 +121,6 @@ CREATE TABLE wcf1_acp_session_virtual ( ipAddress VARCHAR(39) NOT NULL DEFAULT '', userAgent VARCHAR(191) NOT NULL DEFAULT '', lastActivityTime INT(10) NOT NULL DEFAULT 0, - sessionVariables MEDIUMTEXT, UNIQUE KEY (sessionID, ipAddress, userAgent) ); @@ -1095,6 +1095,7 @@ CREATE TABLE wcf1_session ( parentPageID INT(10), parentPageObjectID INT(10), spiderID INT(10), + sessionVariables MEDIUMTEXT, KEY packageID (lastActivityTime, spiderID), KEY pageID (pageID, pageObjectID), KEY parentPageID (parentPageID, parentPageObjectID), @@ -1108,7 +1109,6 @@ CREATE TABLE wcf1_session_virtual ( ipAddress VARCHAR(39) NOT NULL DEFAULT '', userAgent VARCHAR(191) NOT NULL DEFAULT '', lastActivityTime INT(10) NOT NULL DEFAULT 0, - sessionVariables MEDIUMTEXT, UNIQUE KEY (sessionID, ipAddress, userAgent) ); -- 2.20.1