Skip to content

Commit 360bb8c

Browse files
committed
Describe the reasoning behind the modified query
1 parent 765901c commit 360bb8c

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

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

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -588,9 +588,17 @@ private function getExistingSession(string $sessionID): bool
588588

589589
$spiderIdentifier = SpiderHandler::getInstance()->getIdentifier(UserUtil::getUserAgent());
590590
if ($spiderIdentifier === null) {
591-
$condition->add('(sessionID = ? AND spiderIdentifier IS NULL)', [
592-
$row['sessionID'],
593-
]);
591+
// MySQL 8.4 does not like `OR spiderIdentifier = ?` with the
592+
// placeholder being supplied with `NULL`. Instead of raising
593+
// a warning or something, it will cause the query planer to
594+
// pick some odd indices to work with instead of focusing on
595+
// the session id.
596+
//
597+
// Technically we don’t care for the spider identifier at
598+
// this point which means that we can optimize the query
599+
// right away. This query also lives in the hot path of a
600+
// request which makes it even more reasonable.
601+
$condition->add('sessionID = ?', [$row['sessionID']]);
594602
} else {
595603
$condition->add('(sessionID = ? OR spiderIdentifier = ?)', [
596604
$row['sessionID'],

0 commit comments

Comments
 (0)