Przeglądaj źródła

Fix Search\Index

For SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '... for key 'forum_search_words_word_idx'
Visman 3 lat temu
rodzic
commit
aa90fb1d5e
1 zmienionych plików z 6 dodań i 5 usunięć
  1. 6 5
      app/Models/Search/Index.php

+ 6 - 5
app/Models/Search/Index.php

@@ -140,16 +140,17 @@ class Index extends Method
      */
     protected function words(string $text): array
     {
-        $text = $this->model->cleanText($text, true);
-
+        $text  = $this->model->cleanText($text, true);
         $words = [];
-        foreach (\array_unique(\explode(' ', $text)) as $word) {
+
+        foreach (\explode(' ', $text) as $word) {
             $word = $this->model->word($word, true);
+
             if (null !== $word) {
-                $words[] = $word;
+                $words[$word] = $word;
             }
         }
 
-        return $words;
+        return \array_values($words);
     }
 }