From 3b171ffc5a1c0a2a04c912d6fc455afca21d20de Mon Sep 17 00:00:00 2001 From: Daku Date: Sat, 21 May 2016 07:42:17 +0100 Subject: [PATCH] fix single tag wildcard searches returning duplicate results if image has more than one match --- core/imageboard.pack.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/core/imageboard.pack.php b/core/imageboard.pack.php index 1d8365f7..308faf2a 100644 --- a/core/imageboard.pack.php +++ b/core/imageboard.pack.php @@ -1038,12 +1038,14 @@ class Image { else if($positive_tag_count === 1 && $negative_tag_count === 0) { // MySQL is braindead, and does a full table scan on images, running the subquery once for each row -_- // "{$this->get_images} WHERE images.id IN (SELECT image_id FROM tags WHERE tag LIKE ?) ", + $group_by = ((strpos($tag_search->variables['tag0'], '%') !== FALSE) ? "GROUP BY images.id" : ""); $query = new Querylet(" SELECT images.* FROM images JOIN image_tags ON images.id=image_tags.image_id JOIN tags ON image_tags.tag_id=tags.id WHERE tag LIKE :tag0 + {$group_by} ", $tag_search->variables); if(!empty($img_search->sql)) {