From 2bdc0aef99aee2044593f0cc364012952830a925 Mon Sep 17 00:00:00 2001 From: Erik Bernhardson Date: Tue, 14 Mar 2017 13:10:23 -0700 Subject: [PATCH] Revert "[search] Remove more dead code" This reverts commit 1525f6cd45e47c4e9623da234a1d55f862b39498. This should be functionally equivilent to what was being done before. When go is triggered but does not cause a redirect the hook is called. Nothing is done with the result of the hook, same as before. Not going to bother deprecating, it doesn't particularly hurt the architecture in any way, it was removed for being what appeared as dead code due to a long removed feature. There are apparently a few usages of this in extensions that may or may not work with recent releases of mediawiki. Bug: T160441 Change-Id: I368dec79431fbcc8d04f95afed8bbc7262a2e5de --- docs/hooks.txt | 6 ++++-- includes/specials/SpecialSearch.php | 6 ++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/docs/hooks.txt b/docs/hooks.txt index 149ee4b036..4b356dd087 100644 --- a/docs/hooks.txt +++ b/docs/hooks.txt @@ -3160,8 +3160,10 @@ $term: The string the user searched for $title: The title the 'go' feature has decided to forward the user to &$url: Initially null, hook subscribers can set this to specify the final url to redirect to -'SpecialSearchNogomatch': Called when user clicked the "Go" button but the -target doesn't exist. +'SpecialSearchNogomatch': Called when the 'Go' feature is triggered (generally +from autocomplete search other than the main bar on Special:Search) and the +target doesn't exist. Full text search results are generated after this hook is +called. &$title: title object generated from the text entered by the user 'SpecialSearchPowerBox': The equivalent of SpecialSearchProfileForm for diff --git a/includes/specials/SpecialSearch.php b/includes/specials/SpecialSearch.php index b7356e7509..9cc0048aab 100644 --- a/includes/specials/SpecialSearch.php +++ b/includes/specials/SpecialSearch.php @@ -146,6 +146,12 @@ class SpecialSearch extends SpecialPage { $out->redirect( $url ); return; } + // No match. If it could plausibly be a title + // run the No go match hook. + $title = Title::newFromText( $term ); + if ( !is_null( $title ) ) { + Hooks::run( 'SpecialSearchNogomatch', [ &$title ] ); + } } $this->setupPage( $term ); -- 2.20.1