Clarify that $terms get preg_quoted by caller in SearchHighlighter
authorBrian Wolff <bawolff+wn@gmail.com>
Tue, 6 Sep 2016 19:42:12 +0000 (19:42 +0000)
committerBrian Wolff <bawolff+wn@gmail.com>
Tue, 6 Sep 2016 19:42:12 +0000 (19:42 +0000)
Also fix misleading comment about which highlighter implementation
is default.

Change-Id: Ifb4d7fa79ec6325bdb0667fc10b6a1547b32ef69

includes/search/SearchHighlighter.php

index 2bd1955..dd41a6e 100644 (file)
@@ -34,10 +34,11 @@ class SearchHighlighter {
        }
 
        /**
-        * Default implementation of wikitext highlighting
+        * Wikitext highlighting when $wgAdvancedSearchHighlighting = true
         *
         * @param string $text
-        * @param array $terms Terms to highlight (unescaped)
+        * @param array $terms Terms to highlight (not html escaped but
+        *   regex escaped via SearchDatabase::regexTerm())
         * @param int $contextlines
         * @param int $contextchars
         * @return string
@@ -145,7 +146,6 @@ class SearchHighlighter {
                }
                $anyterm = implode( '|', $terms );
                $phrase = implode( "$wgSearchHighlightBoundaries+", $terms );
-
                // @todo FIXME: A hack to scale contextchars, a correct solution
                // would be to have contextchars actually be char and not byte
                // length, and do proper utf-8 substrings and lengths everywhere,
@@ -485,8 +485,10 @@ class SearchHighlighter {
         * Simple & fast snippet extraction, but gives completely unrelevant
         * snippets
         *
+        * Used when $wgAdvancedSearchHighlighting is false.
+        *
         * @param string $text
-        * @param array $terms
+        * @param array $terms Escaped for regex by SearchDatabase::regexTerm()
         * @param int $contextlines
         * @param int $contextchars
         * @return string