Merge "Add part to update ctd_user_defined in populateChangeTagDef"
[lhc/web/wiklou.git] / includes / search / SearchNearMatcher.php
index 8e86865..0a64493 100644 (file)
@@ -6,8 +6,7 @@
  */
 class SearchNearMatcher {
        /**
-        * Configuration object.
-        * @param Config $config
+        * @var Config
         */
        protected $config;
 
@@ -54,7 +53,6 @@ class SearchNearMatcher {
         */
        protected function getNearMatchInternal( $searchterm ) {
                $lang = $this->language;
-
                $allSearchTerms = [ $searchterm ];
 
                if ( $lang->hasVariants() ) {
@@ -69,6 +67,13 @@ class SearchNearMatcher {
                        return $titleResult;
                }
 
+               // Most of our handling here deals with finding a valid title for the search term,
+               // but almost anything starting with '#' is "valid" and points to Main_Page#searchterm.
+               // Rather than doing something completely wrong, do nothing.
+               if ( $searchterm === '' || $searchterm[0] === '#' ) {
+                       return null;
+               }
+
                foreach ( $allSearchTerms as $term ) {
                        # Exact match? No need to look further.
                        $title = Title::newFromText( $term );