From: Reedy Date: Fri, 2 Nov 2012 16:56:36 +0000 (+0000) Subject: Addition of SearchAfterNoDirectMatch hook X-Git-Tag: 1.31.0-rc.0~21485^2 X-Git-Url: http://git.cyclocoop.org/%24href?a=commitdiff_plain;h=904e4bdf7f332b2b707cd925943dcba5e4ab89d9;p=lhc%2Fweb%2Fwiklou.git Addition of SearchAfterNoDirectMatch hook Needed for mediawiki/extensions/SearchExtraNS Change-Id: If0a7da5c8691c418bc388e50dd11eea3b57ed45d --- 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;