From 904e4bdf7f332b2b707cd925943dcba5e4ab89d9 Mon Sep 17 00:00:00 2001 From: Reedy Date: Fri, 2 Nov 2012 16:56:36 +0000 Subject: [PATCH] Addition of SearchAfterNoDirectMatch hook Needed for mediawiki/extensions/SearchExtraNS Change-Id: If0a7da5c8691c418bc388e50dd11eea3b57ed45d --- docs/hooks.txt | 6 ++++++ includes/search/SearchEngine.php | 7 ++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/docs/hooks.txt b/docs/hooks.txt index 998523f334..45687a4742 100644 --- a/docs/hooks.txt +++ b/docs/hooks.txt @@ -1791,6 +1791,12 @@ $text : Current text being indexed $allSearchTerms : Array of the search terms in all content languages &$titleResult : Outparam; the value to return. A Title object or null. +'SearchAfterNoDirectMatch': If there was no match for the exact result. This +runs before lettercase variants are attempted, whereas 'SearchGetNearMatch' +runs after. +$term : Search term string +&$title : Outparam; set to $title object and return false for a match + 'SearchGetNearMatch': An extra chance for exact-title-matches in "go" searches if nothing was found $term : Search term string &$title : Outparam; set to $title object and return false for a match diff --git a/includes/search/SearchEngine.php b/includes/search/SearchEngine.php index f8f5fa59f6..562759a065 100644 --- a/includes/search/SearchEngine.php +++ b/includes/search/SearchEngine.php @@ -197,22 +197,23 @@ class SearchEngine { return $title; } + if ( !wfRunHooks( 'SearchAfterNoDirectMatch', array( $term, &$title ) ) ) { + return $title; + } + # Now try all lower case (i.e. first letter capitalized) - # $title = Title::newFromText( $wgContLang->lc( $term ) ); if ( $title && $title->exists() ) { return $title; } # Now try capitalized string - # $title = Title::newFromText( $wgContLang->ucwords( $term ) ); if ( $title && $title->exists() ) { return $title; } # Now try all upper case - # $title = Title::newFromText( $wgContLang->uc( $term ) ); if ( $title && $title->exists() ) { return $title; -- 2.20.1