From: joshuaruesweg Date: Mon, 26 Oct 2020 13:35:28 +0000 (+0100) Subject: Add new intern method to delete sessions X-Git-Tag: 5.4.0_Alpha_1~656^2~12 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=57f6be85a42386ed7568654423646ffe58aa05dd;p=GitHub%2FWoltLab%2FWCF.git Add new intern method to delete sessions --- diff --git a/wcfsetup/install/files/lib/system/session/SessionHandler.class.php b/wcfsetup/install/files/lib/system/session/SessionHandler.class.php index f1ab8b7071..374138084f 100644 --- a/wcfsetup/install/files/lib/system/session/SessionHandler.class.php +++ b/wcfsetup/install/files/lib/system/session/SessionHandler.class.php @@ -1088,32 +1088,40 @@ final class SessionHandler extends SingletonFactory { } /** - * Deletes a user session with the given session id. + * Deletes a user session with the given session ID. * * @since 5.4 */ public function deleteUserSession(string $sessionID): void { - $sql = "DELETE FROM wcf".WCF_N."_user_session - WHERE sessionID = ?"; - $statement = WCF::getDB()->prepareStatement($sql); - $statement->execute([$sessionID]); - - // Delete legacy session. - $sql = "DELETE FROM wcf".WCF_N."_session - WHERE sessionID = ?"; - $statement = WCF::getDB()->prepareStatement($sql); - $statement->execute([$sessionID]); + $this->deleteSession($sessionID); } /** - * Deletes a acp session with the given session id. + * Deletes an acp session with the given session ID. * * @since 5.4 */ public function deleteAcpSession(string $sessionID): void { - $sql = "DELETE FROM wcf".WCF_N."_acp_session + $this->deleteSession($sessionID, true); + } + + /** + * Deletes a session with the given session ID. + * + * @since 5.4 + */ + private function deleteSession(string $sessionID, bool $isAcp = false): void { + $sql = "DELETE FROM wcf".WCF_N."_". ($isAcp ? 'acp' : 'user') ."_session WHERE sessionID = ?"; $statement = WCF::getDB()->prepareStatement($sql); $statement->execute([$sessionID]); + + if (!$isAcp) { + // Delete legacy session. + $sql = "DELETE FROM wcf".WCF_N."_session + WHERE sessionID = ?"; + $statement = WCF::getDB()->prepareStatement($sql); + $statement->execute([$sessionID]); + } } }