Revert "[search] Remove more dead code"
authorErik Bernhardson <ebernhardson@wikimedia.org>
Tue, 14 Mar 2017 20:10:23 +0000 (13:10 -0700)
committerErik Bernhardson <ebernhardson@wikimedia.org>
Tue, 14 Mar 2017 20:11:04 +0000 (13:11 -0700)
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
includes/specials/SpecialSearch.php

index 149ee4b..4b356dd 100644 (file)
@@ -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
index b7356e7..9cc0048 100644 (file)
@@ -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 );