*/
protected function getNearMatchInternal( $searchterm ) {
$lang = $this->language;
-
$allSearchTerms = [ $searchterm ];
if ( $lang->hasVariants() ) {
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 );
# Quoted term? Try without the quotes...
$matches = [];
if ( preg_match( '/^"([^"]+)"$/', $searchterm, $matches ) ) {
- return self::getNearMatch( $matches[1] );
+ return $this->getNearMatch( $matches[1] );
}
return null;