Merge "Revert "[search] Remove more dead code""
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Thu, 16 Mar 2017 11:09:43 +0000 (11:09 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Thu, 16 Mar 2017 11:09:44 +0000 (11:09 +0000)
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 );