fixes bug where materialized metas would still be processes separately, a=chris

Chris Pollett [2015-08-13 16:Aug:th]
fixes bug where materialized metas would still be processes separately, a=chris
Filename
src/models/PhraseModel.php
diff --git a/src/models/PhraseModel.php b/src/models/PhraseModel.php
index 77f17f4eb..f024632ad 100755
--- a/src/models/PhraseModel.php
+++ b/src/models/PhraseModel.php
@@ -615,6 +615,7 @@ class PhraseModel extends ParallelModel
             $hashes = [];
             $metas_accounted = false;
             $materialized_metas = [];
+            $meta_keys = [];
             foreach ($words as $word) {
                 if (!$metas_accounted && substr_count($word, " ") == 0
                     && !in_array($word, $found_metas)) {
@@ -626,11 +627,18 @@ class PhraseModel extends ParallelModel
                 if ($index_version == 0) {
                     $tmp_hash = (is_array($tmp_hash)) ? $tmp_hash : [$tmp_hash];
                     $test =  array_merge($tmp_hash, [L\crawlHash($word)]);
-                    $word_keys[] = $test;
                 } else {
-                    $word_keys[] = $tmp_hash;
+                    if(in_array($word, $found_materialized_metas) &&
+                        !$metas_accounted) {
+                        $meta_keys[] = $tmp_hash;
+                    } else {
+                        $word_keys[] = $tmp_hash;
+                    }
                 }
             }
+            if(!$metas_accounted) {
+                $word_keys = array_merge($word_keys, $meta_keys);
+            }
             if (!isset($word_keys) || count($word_keys) == 0) {
                 $word_keys = null;
                 $word_struct = null;
@@ -781,7 +789,8 @@ class PhraseModel extends ParallelModel
         }
         $found_metas = array_unique($found_metas);
         $found_materialized_metas = array_unique($found_materialized_metas);
-        if(count($found_metas) == 2 && (in_array("site:doc", $found_metas)
+        if(empty(trim($phrase_string)) && count($found_metas) == 2
+            && (in_array("site:doc", $found_metas)
             || in_array("site:any", $found_metas))) {
             /*site:doc and site:any doesn't work with materialized metas by
               themselves */
@@ -1134,6 +1143,7 @@ class PhraseModel extends ParallelModel
             }
         }
         $old_to_retrieve = $to_retrieve;
+
         $query_iterator = $this->getQueryIterator($word_structs, $filter, $raw,
             $to_retrieve, $queue_servers, $original_query,
             $save_timestamp_name, $limit_news);
ViewGit