X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fsearch%2FSearchNearMatcher.php;h=9ee3e175861917a5bc96ec65917ade3911c671d9;hb=0a4c2670a19923e3cb7556003c0793def40765e9;hp=27046f31561f610b169b7d86ecdd1ec3d92d8dac;hpb=0cd28e19cb0f9385a2a1cc11a4d8c9c21ff0b830;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/search/SearchNearMatcher.php b/includes/search/SearchNearMatcher.php index 27046f3156..9ee3e17586 100644 --- a/includes/search/SearchNearMatcher.php +++ b/includes/search/SearchNearMatcher.php @@ -53,7 +53,6 @@ class SearchNearMatcher { */ protected function getNearMatchInternal( $searchterm ) { $lang = $this->language; - $allSearchTerms = [ $searchterm ]; if ( $lang->hasVariants() ) { @@ -68,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 ); @@ -159,7 +165,7 @@ class SearchNearMatcher { # Quoted term? Try without the quotes... $matches = []; if ( preg_match( '/^"([^"]+)"$/', $searchterm, $matches ) ) { - return self::getNearMatch( $matches[1] ); + return $this->getNearMatch( $matches[1] ); } return null;