Incorrect usage of `NOT IN()` for columns that accept `NULL`
authorAlexander Ebert <ebert@woltlab.com>
Sun, 16 Feb 2020 17:06:29 +0000 (18:06 +0100)
committerAlexander Ebert <ebert@woltlab.com>
Sun, 16 Feb 2020 17:06:29 +0000 (18:06 +0100)
`NULL` is considered to fail the condition `NOT IN (1, 2, …)`.

wcfsetup/install/files/lib/system/box/AbstractCommentListBoxController.class.php

index ce1eb865e79fb21d6f2e7569d51ddbdfccb9f7f0..cd4a0f60c62cbb894c4141ce9cd1413ad328a5a5 100644 (file)
@@ -86,7 +86,7 @@ abstract class AbstractCommentListBoxController extends AbstractDatabaseObjectLi
                $this->applyObjectTypeFilters($commentList);
                
                if (!empty(UserProfileHandler::getInstance()->getIgnoredUsers())) {
-                       $commentList->getConditionBuilder()->add("comment.userID NOT IN (?)", [UserProfileHandler::getInstance()->getIgnoredUsers()]);
+                       $commentList->getConditionBuilder()->add("(comment.userID IS NULL OR comment.userID NOT IN (?))", [UserProfileHandler::getInstance()->getIgnoredUsers()]);
                }
                
                return $commentList;