From 9f06a5c5656049c923d5c6361c0217d010729b86 Mon Sep 17 00:00:00 2001 From: Daku Date: Fri, 3 Jan 2014 00:41:28 +0000 Subject: [PATCH] fix search not working properly for aliases to multiple tags fix issue 359 --- core/imageboard.pack.php | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/core/imageboard.pack.php b/core/imageboard.pack.php index c9a2ce4a..eb34035e 100644 --- a/core/imageboard.pack.php +++ b/core/imageboard.pack.php @@ -663,6 +663,8 @@ class Image { } } + $terms = Tag::resolve_aliases($terms); + // parse the words that are searched for into // various types of querylet foreach($terms as $term) { @@ -675,8 +677,6 @@ class Image { continue; } - $term = Tag::resolve_alias($term); - $stpe = new SearchTermParseEvent($term, $terms); send_event($stpe); if($stpe->is_querylet_set()) { @@ -824,6 +824,8 @@ class Image { } } + $terms = Tag::resolve_aliases($terms); + reset($terms); // rewind to first element in array. // turn each term into a specific type of querylet @@ -833,8 +835,6 @@ class Image { $negative = true; $term = substr($term, 1); } - - $term = Tag::resolve_alias($term); $stpe = new SearchTermParseEvent($term, $terms); send_event($stpe); @@ -1082,11 +1082,22 @@ class Tag { assert(is_array($tags)); $new = array(); - foreach($tags as $tag) { - $new_set = explode(' ', Tag::resolve_alias($tag)); - foreach($new_set as $new_one) { - $new[] = $new_one; + + $i = 0; + $tag_count = count($tags); + while($i<$tag_count) { + $aliases = explode(' ', Tag::resolve_alias($tags[$i])); + foreach($aliases as $alias){ + if(!in_array($alias, $new)){ + if($tags[$i] == $alias){ + $new[] = $alias; + }elseif(!in_array($alias, $tags)){ + $tags[] = $alias; + $tag_count++; + } + } } + $i++; } $new = array_iunique($new); // remove any duplicate tags