From: Tim Düsterhus Date: Tue, 2 Feb 2021 10:31:21 +0000 (+0100) Subject: Make 5.4_session_3_migrate_session.php idempotent X-Git-Tag: 5.4.0_Alpha_1~327 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=ea52aa0856fab23d08b4620b68631bc154639eab;p=GitHub%2FWoltLab%2FWCF.git Make 5.4_session_3_migrate_session.php idempotent Fixes #3923 --- 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 a50a88ce15..a828489a90 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 @@ -12,6 +12,19 @@ use wcf\system\session\SessionHandler; use wcf\system\WCF; +$sql = "SELECT userID + FROM wcf" . WCF_N . "_user_session + WHERE sessionID = ?"; +$statement = WCF::getDB()->prepareStatement($sql); +$statement->execute([ + SessionHandler::getInstance()->sessionID, +]); + +// Check if a matching session already exists. +if ($statement->fetchSingleColumn() == SessionHandler::getInstance()->userID) { + return; +} + $sql = "INSERT INTO wcf" . WCF_N . "_user_session (sessionID, userID, userAgent, ipAddress, lastActivityTime, sessionVariables) VALUES (?, ?, ?, ?, ?, ?)";