Pass $opts by reference to subscribers of 'SpecialSearchPowerBox' hook to allow them...
authorJack Phoenix <ashley@uncyclomedia.co>
Wed, 11 Jul 2018 08:06:10 +0000 (11:06 +0300)
committerBrian Wolff <bawolff+wn@gmail.com>
Sat, 14 Jul 2018 22:42:41 +0000 (22:42 +0000)
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
docs/hooks.txt
includes/widget/search/SearchFormWidget.php

index 18ddc2f..5110e51 100644 (file)
@@ -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 ===
 * …
index 5f39aa9..c7874c3 100644 (file)
@@ -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
index 2c88563..e40ae29 100644 (file)
@@ -270,7 +270,7 @@ class SearchFormWidget {
                $showSections = [
                        'namespaceTables' => "<table>" . implode( '</table><table>', $namespaceTables ) . '</table>',
                ];
-               Hooks::run( 'SpecialSearchPowerBox', [ &$showSections, $term, $opts ] );
+               Hooks::run( 'SpecialSearchPowerBox', [ &$showSections, $term, &$opts ] );
 
                $hidden = '';
                foreach ( $opts as $key => $value ) {