Addition of SearchAfterNoDirectMatch hook
authorReedy <reedy@wikimedia.org>
Fri, 2 Nov 2012 16:56:36 +0000 (16:56 +0000)
committerOri Livneh <ori@wikimedia.org>
Wed, 28 Nov 2012 11:47:17 +0000 (03:47 -0800)
Needed for mediawiki/extensions/SearchExtraNS

Change-Id: If0a7da5c8691c418bc388e50dd11eea3b57ed45d

docs/hooks.txt
includes/search/SearchEngine.php

index 998523f..45687a4 100644 (file)
@@ -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
index f8f5fa5..562759a 100644 (file)
@@ -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;