From f29e192da9e56354e296b6d4f4726d4b5adab1c4 Mon Sep 17 00:00:00 2001 From: Bryan Tong Minh Date: Mon, 13 Dec 2010 20:00:43 +0000 Subject: [PATCH] Follow-up r78297: allow the hook to break the execution; added &$term: could be useful for modifying the edit link --- docs/hooks.txt | 1 + includes/specials/SpecialSearch.php | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/docs/hooks.txt b/docs/hooks.txt index e528d7a3cf..2fc81d9211 100644 --- a/docs/hooks.txt +++ b/docs/hooks.txt @@ -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 diff --git a/includes/specials/SpecialSearch.php b/includes/specials/SpecialSearch.php index 1d5dfd7d94..b3812e3c29 100644 --- a/includes/specials/SpecialSearch.php +++ b/includes/specials/SpecialSearch.php @@ -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; -- 2.20.1