From f8f8fc9021c80daef7713a3e586fc1f44aa4359c Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tim=20D=C3=BCsterhus?= Date: Tue, 16 Mar 2021 14:35:38 +0100 Subject: [PATCH] Add wcf1_user_session.creationTime --- .../update_com.woltlab.wcf_5.4_session_2_user_session.php | 1 + ...pdate_com.woltlab.wcf_5.4_session_3_migrate_session.php | 7 ++++--- .../files/lib/system/session/SessionHandler.class.php | 5 +++-- wcfsetup/setup/db/install.sql | 1 + 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/wcfsetup/install/files/acp/database/update_com.woltlab.wcf_5.4_session_2_user_session.php b/wcfsetup/install/files/acp/database/update_com.woltlab.wcf_5.4_session_2_user_session.php index e2b5caa897..c7cb38ecd6 100644 --- a/wcfsetup/install/files/acp/database/update_com.woltlab.wcf_5.4_session_2_user_session.php +++ b/wcfsetup/install/files/acp/database/update_com.woltlab.wcf_5.4_session_2_user_session.php @@ -32,6 +32,7 @@ return [ VarcharDatabaseTableColumn::create('ipAddress') ->length(39) ->defaultValue(''), + NotNullInt10DatabaseTableColumn::create('creationTime'), NotNullInt10DatabaseTableColumn::create('lastActivityTime') ->defaultValue(0), MediumblobDatabaseTableColumn::create('sessionVariables'), diff --git a/wcfsetup/install/files/acp/update_com.woltlab.wcf_5.4_session_3_migrate_session.php b/wcfsetup/install/files/acp/update_com.woltlab.wcf_5.4_session_3_migrate_session.php index a828489a90..f9ac5f394d 100644 --- a/wcfsetup/install/files/acp/update_com.woltlab.wcf_5.4_session_3_migrate_session.php +++ b/wcfsetup/install/files/acp/update_com.woltlab.wcf_5.4_session_3_migrate_session.php @@ -26,8 +26,8 @@ if ($statement->fetchSingleColumn() == SessionHandler::getInstance()->userID) { } $sql = "INSERT INTO wcf" . WCF_N . "_user_session - (sessionID, userID, userAgent, ipAddress, lastActivityTime, sessionVariables) - VALUES (?, ?, ?, ?, ?, ?)"; + (sessionID, userID, userAgent, ipAddress, creationTime, lastActivityTime, sessionVariables) + VALUES (?, ?, ?, ?, ?, ?, ?)"; $statement = WCF::getDB()->prepareStatement($sql); $klass = new \ReflectionClass(SessionHandler::getInstance()); @@ -45,7 +45,8 @@ $statement->execute([ SessionHandler::getInstance()->userID, SessionHandler::getInstance()->userAgent, SessionHandler::getInstance()->ipAddress, - SessionHandler::getInstance()->lastActivityTime, + TIME_NOW, + TIME_NOW, \serialize([ 'acp' => $variables, 'frontend' => [], diff --git a/wcfsetup/install/files/lib/system/session/SessionHandler.class.php b/wcfsetup/install/files/lib/system/session/SessionHandler.class.php index db3fb09f4e..35362f68f1 100644 --- a/wcfsetup/install/files/lib/system/session/SessionHandler.class.php +++ b/wcfsetup/install/files/lib/system/session/SessionHandler.class.php @@ -679,14 +679,15 @@ final class SessionHandler extends SingletonFactory // Create new session. $sql = "INSERT INTO wcf" . WCF_N . "_user_session - (sessionID, ipAddress, userAgent, lastActivityTime, sessionVariables) - VALUES (?, ?, ?, ?, ?)"; + (sessionID, ipAddress, userAgent, creationTime, lastActivityTime, sessionVariables) + VALUES (?, ?, ?, ?, ?, ?)"; $statement = WCF::getDB()->prepareStatement($sql); $statement->execute([ $this->sessionID, UserUtil::getIpAddress(), UserUtil::getUserAgent(), TIME_NOW, + TIME_NOW, \serialize($variables), ]); diff --git a/wcfsetup/setup/db/install.sql b/wcfsetup/setup/db/install.sql index d6f16af643..03b58b8252 100644 --- a/wcfsetup/setup/db/install.sql +++ b/wcfsetup/setup/db/install.sql @@ -1886,6 +1886,7 @@ CREATE TABLE wcf1_user_session ( userID INT(10), ipAddress VARCHAR(39) NOT NULL DEFAULT '', userAgent VARCHAR(255) NOT NULL DEFAULT '', + creationTime INT(10) NOT NULL, lastActivityTime INT(10) NOT NULL DEFAULT 0, sessionVariables MEDIUMBLOB, KEY (userID), -- 2.20.1