Use a `?` placeholder for the `USER_SESSION_LIMIT` in SessionHandler
authorTim Düsterhus <duesterhus@woltlab.com>
Fri, 13 May 2022 09:14:19 +0000 (11:14 +0200)
committerTim Düsterhus <duesterhus@woltlab.com>
Fri, 13 May 2022 09:14:19 +0000 (11:14 +0200)
MySQL supports placeholders within the `LIMIT`, make use of this to avoid the
string concatenation that breaks syntax highlighting of the SQL query within
the IDE.

wcfsetup/install/files/lib/system/session/SessionHandler.class.php

index 248d63be043861b78be11d1cc6ef6623e29f05b8..4a5e23f38cea823d0ae1ebfbe05972c9035e2334 100644 (file)
@@ -1072,7 +1072,7 @@ final class SessionHandler extends SingletonFactory
                         FROM        wcf1_user_session
                         WHERE       userID = ?
                         ORDER BY    lastActivityTime DESC
-                        LIMIT       " . self::USER_SESSION_LIMIT . "
+                        LIMIT       ?
                     ) newest_sessions
                     ON      newest_sessions.sessionID = all_sessions.sessionID
                     WHERE   all_sessions.userID = ?
@@ -1080,6 +1080,7 @@ final class SessionHandler extends SingletonFactory
             $statement = WCF::getDB()->prepare($sql);
             $statement->execute([
                 $user->userID,
+                self::USER_SESSION_LIMIT,
                 $user->userID,
             ]);
             foreach ($statement->fetchAll(\PDO::FETCH_COLUMN) as $sessionID) {