From 358b2d1d7770c8e36219a44bf4f943fe429a46aa Mon Sep 17 00:00:00 2001 From: Jack Phoenix Date: Wed, 11 Jul 2018 11:06:10 +0300 Subject: [PATCH 1/1] Pass $opts by reference to subscribers of 'SpecialSearchPowerBox' hook to allow them to modify it wikiHow added a new hook called 'SpecialSearchPowerBoxOpts', which was passed only &$opts, so that the Finner extension can unset the $opts array. Enhancing the pre-existing hook is a better solution in this case. Change-Id: I091cbdc78fc779144554d8420a95435b7048c407 --- RELEASE-NOTES-1.32 | 2 ++ docs/hooks.txt | 2 +- includes/widget/search/SearchFormWidget.php | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/RELEASE-NOTES-1.32 b/RELEASE-NOTES-1.32 index 18ddc2f759..5110e5190d 100644 --- a/RELEASE-NOTES-1.32 +++ b/RELEASE-NOTES-1.32 @@ -51,6 +51,8 @@ production. * Added new 'ArticleShowPatrolFooter' hook, which allows extensions to determine if the [mark as patrolled] link should be shown at the footer of patrollable pages. +* The array of hidden options ($opts) passed to the 'SpecialSearchPowerBox' hook + is now passed by reference, allowing extensions to modify or even unset it. === External library changes in 1.32 === * … diff --git a/docs/hooks.txt b/docs/hooks.txt index 5f39aa956e..c7874c33af 100644 --- a/docs/hooks.txt +++ b/docs/hooks.txt @@ -3344,7 +3344,7 @@ called. the advanced form, a.k.a. power search box. &$showSections: an array to add values with more options to $term: the search term (not a title object) -$opts: an array of hidden options (containing 'redirs' and 'profile') +&$opts: an array of hidden options (containing 'redirs' and 'profile') 'SpecialSearchProfileForm': Allows modification of search profile forms. $search: special page object diff --git a/includes/widget/search/SearchFormWidget.php b/includes/widget/search/SearchFormWidget.php index 2c885630aa..e40ae2909a 100644 --- a/includes/widget/search/SearchFormWidget.php +++ b/includes/widget/search/SearchFormWidget.php @@ -270,7 +270,7 @@ class SearchFormWidget { $showSections = [ 'namespaceTables' => "" . implode( '
', $namespaceTables ) . '
', ]; - Hooks::run( 'SpecialSearchPowerBox', [ &$showSections, $term, $opts ] ); + Hooks::run( 'SpecialSearchPowerBox', [ &$showSections, $term, &$opts ] ); $hidden = ''; foreach ( $opts as $key => $value ) { -- 2.20.1