Follow-up r78297: allow the hook to break the execution; added &$term: could be usefu...
authorBryan Tong Minh <btongminh@users.mediawiki.org>
Mon, 13 Dec 2010 20:00:43 +0000 (20:00 +0000)
committerBryan Tong Minh <btongminh@users.mediawiki.org>
Mon, 13 Dec 2010 20:00:43 +0000 (20:00 +0000)
docs/hooks.txt
includes/specials/SpecialSearch.php

index e528d7a..2fc81d9 100644 (file)
@@ -1609,6 +1609,7 @@ $opts: FormOptions for this request
 
 'SpecialSearchGo': called when user clicked the "Go"
 &$title: title object generated from the text entered by the user
+&$term: the search term entered by the user
 
 'SpecialSearchNogomatch': called when user clicked the "Go" button but the
 target doesn't exist
index 1d5dfd7..b3812e3 100644 (file)
@@ -102,7 +102,12 @@ class SpecialSearch extends SpecialPage {
                }
                # If there's an exact or very near match, jump right there.
                $t = SearchEngine::getNearMatch( $term );
-               wfRunHooks( 'SpecialSearchGo', array( &$t ) );
+               
+               if ( !wfRunHooks( 'SpecialSearchGo', array( &$t, &$term ) ) ) {
+                       # Hook requested termination
+                       return;
+               }
+               
                if( !is_null( $t ) ) {
                        $wgOut->redirect( $t->getFullURL() );
                        return;