fix search not working properly for aliases to multiple tags

fix issue 359
This commit is contained in:
Daku 2014-01-03 00:41:28 +00:00
parent 14899e79ad
commit 9f06a5c565

View file

@ -663,6 +663,8 @@ class Image {
} }
} }
$terms = Tag::resolve_aliases($terms);
// parse the words that are searched for into // parse the words that are searched for into
// various types of querylet // various types of querylet
foreach($terms as $term) { foreach($terms as $term) {
@ -675,8 +677,6 @@ class Image {
continue; continue;
} }
$term = Tag::resolve_alias($term);
$stpe = new SearchTermParseEvent($term, $terms); $stpe = new SearchTermParseEvent($term, $terms);
send_event($stpe); send_event($stpe);
if($stpe->is_querylet_set()) { if($stpe->is_querylet_set()) {
@ -824,6 +824,8 @@ class Image {
} }
} }
$terms = Tag::resolve_aliases($terms);
reset($terms); // rewind to first element in array. reset($terms); // rewind to first element in array.
// turn each term into a specific type of querylet // turn each term into a specific type of querylet
@ -834,8 +836,6 @@ class Image {
$term = substr($term, 1); $term = substr($term, 1);
} }
$term = Tag::resolve_alias($term);
$stpe = new SearchTermParseEvent($term, $terms); $stpe = new SearchTermParseEvent($term, $terms);
send_event($stpe); send_event($stpe);
if($stpe->is_querylet_set()) { if($stpe->is_querylet_set()) {
@ -1082,11 +1082,22 @@ class Tag {
assert(is_array($tags)); assert(is_array($tags));
$new = array(); $new = array();
foreach($tags as $tag) {
$new_set = explode(' ', Tag::resolve_alias($tag)); $i = 0;
foreach($new_set as $new_one) { $tag_count = count($tags);
$new[] = $new_one; 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 $new = array_iunique($new); // remove any duplicate tags