From b5ce7632c7aa5e4e343db0292f24b0b570fdc9e7 Mon Sep 17 00:00:00 2001 From: "James D. Forrester" Date: Wed, 12 Sep 2018 12:43:01 -0700 Subject: [PATCH] hooks: Drop Special{Watchlist|RecentChanges}Filters, deprecated in 1.23 Neither SpecialWatchlistFilters nor SpecialRecentChangesFilters are used in any code known to Wikimedia code search. The related code to use these hooks was only ever used within the MediaWiki repo. Change-Id: Ib631d49d7b5835c665171dbad3e8a646b80827ef --- RELEASE-NOTES-1.32 | 7 +++ docs/hooks.txt | 16 ------ includes/changes/ChangesListBooleanFilter.php | 7 --- .../specialpage/ChangesListSpecialPage.php | 53 +------------------ includes/specials/SpecialRecentchanges.php | 14 ----- includes/specials/SpecialWatchlist.php | 14 ----- .../ChangesListSpecialPageTest.php | 37 ------------- 7 files changed, 9 insertions(+), 139 deletions(-) diff --git a/RELEASE-NOTES-1.32 b/RELEASE-NOTES-1.32 index 041b3d73db..52dbbffe60 100644 --- a/RELEASE-NOTES-1.32 +++ b/RELEASE-NOTES-1.32 @@ -295,6 +295,13 @@ because of Phabricator reports. * 'uppercase-se' (NorthernSamiUppercaseCollation) - use 'uca-se' instead * 'xx-uca-et' (CollationEt) - use 'uca-et' instead * 'xx-uca-fa' (CollationFa) - use 'uca-fa' instead +* The hooks 'SpecialRecentChangesFilters' & 'SpecialWatchlistFilters' deprecated + in 1.23 were removed. Instead, use 'ChangesListSpecialPageStructuredFilters'. + The ChangesListSpecialPage code for these legacy hooks, and their use in + SpecialRecentchanges.php and SpecialWatchlist, was also removed: + * ChangesListSpecialPage->getCustomFilters() + * ChangesListSpecialPage->getFilterGroupDefinitionFromLegacyCustomFilters() + * ChangesListSpecialPage::customFilters === Deprecations in 1.32 === * HTMLForm::setSubmitProgressive() is deprecated. No need to call it. Submit diff --git a/docs/hooks.txt b/docs/hooks.txt index cce50e058c..9a53ccfaf0 100644 --- a/docs/hooks.txt +++ b/docs/hooks.txt @@ -3320,14 +3320,6 @@ use this to change some selection criteria or substitute a different title. &$title: If the hook returns false, a Title object to use instead of the result from the normal query -'SpecialRecentChangesFilters': DEPRECATED since 1.23! Use -ChangesListSpecialPageStructuredFilters instead. -Called after building form options at RecentChanges. -$special: the special page object -&$filters: associative array of filter definitions. The keys are the HTML - name/URL parameters. Each key maps to an associative array with a 'msg' - (message key) and a 'default' value. - 'SpecialRecentChangesPanel': Called when building form options in SpecialRecentChanges. &$extraOpts: array of added items, to which can be added @@ -3442,14 +3434,6 @@ Special:Upload. $wgVersion: Current $wgVersion for you to use &$versionUrl: Raw url to link to (eg: release notes) -'SpecialWatchlistFilters': DEPRECATED since 1.23! Use -ChangesListSpecialPageStructuredFilters instead. -Called after building form options at Watchlist. -$special: the special page object -&$filters: associative array of filter definitions. The keys are the HTML - name/URL parameters. Each key maps to an associative array with a 'msg' - (message key) and a 'default' value. - 'SpecialWatchlistGetNonRevisionTypes': Called when building sql query for SpecialWatchlist. Allows extensions to register custom values they have inserted to rc_type so they can be returned as part of the watchlist. diff --git a/includes/changes/ChangesListBooleanFilter.php b/includes/changes/ChangesListBooleanFilter.php index fc37882c02..c781d717cc 100644 --- a/includes/changes/ChangesListBooleanFilter.php +++ b/includes/changes/ChangesListBooleanFilter.php @@ -29,13 +29,6 @@ use Wikimedia\Rdbms\IDatabase; * @since 1.29 */ class ChangesListBooleanFilter extends ChangesListFilter { - // This can sometimes be different on Special:RecentChanges - // and Special:Watchlist, due to the double-legacy hooks - // (SpecialRecentChangesFilters and SpecialWatchlistFilters) - - // but there will be separate sets of ChangesListFilterGroup and ChangesListFilter instances - // for those pages (it should work even if they're both loaded - // at once, but that can't happen). /** * Main unstructured UI i18n key * diff --git a/includes/specialpage/ChangesListSpecialPage.php b/includes/specialpage/ChangesListSpecialPage.php index caa039b5e9..43b4e98663 100644 --- a/includes/specialpage/ChangesListSpecialPage.php +++ b/includes/specialpage/ChangesListSpecialPage.php @@ -69,9 +69,6 @@ abstract class ChangesListSpecialPage extends SpecialPage { /** @var FormOptions */ protected $rcOptions; - /** @var array */ - protected $customFilters; - // Order of both groups and filters is significant; first is top-most priority, // descending from there. // 'showHideSuffix' is a shortcut to and avoid spelling out @@ -84,8 +81,7 @@ abstract class ChangesListSpecialPage extends SpecialPage { * * Groups are displayed to the user in the structured UI. However, if necessary, * all of the filters in a group can be configured to only display on the - * unstuctured UI, in which case you don't need a group title. This is done in - * getFilterGroupDefinitionFromLegacyCustomFilters, for example. + * unstuctured UI, in which case you don't need a group title. * * @var array $filterGroupDefinitions */ @@ -987,11 +983,7 @@ abstract class ChangesListSpecialPage extends SpecialPage { Hooks::run( 'ChangesListSpecialPageStructuredFilters', [ $this ] ); - $unstructuredGroupDefinition = - $this->getFilterGroupDefinitionFromLegacyCustomFilters( - $this->getCustomFilters() - ); - $this->registerFiltersFromDefinitions( [ $unstructuredGroupDefinition ] ); + $this->registerFiltersFromDefinitions( [] ); $userExperienceLevel = $this->getFilterGroup( 'userExpLevel' ); $registered = $userExperienceLevel->getFilter( 'registered' ); @@ -1074,32 +1066,6 @@ abstract class ChangesListSpecialPage extends SpecialPage { } } - /** - * Get filter group definition from legacy custom filters - * - * @param array $customFilters Custom filters from legacy hooks - * @return array Group definition - */ - protected function getFilterGroupDefinitionFromLegacyCustomFilters( array $customFilters ) { - // Special internal unstructured group - $unstructuredGroupDefinition = [ - 'name' => 'unstructured', - 'class' => ChangesListBooleanFilterGroup::class, - 'priority' => -1, // Won't display in structured - 'filters' => [], - ]; - - foreach ( $customFilters as $name => $params ) { - $unstructuredGroupDefinition['filters'][] = [ - 'name' => $name, - 'showHide' => $params['msg'], - 'default' => $params['default'], - ]; - } - - return $unstructuredGroupDefinition; - } - /** * @return array The legacy show/hide toggle filters */ @@ -1245,21 +1211,6 @@ abstract class ChangesListSpecialPage extends SpecialPage { return $output; } - /** - * Get custom show/hide filters using deprecated ChangesListSpecialPageFilters - * hook. - * - * @return array Map of filter URL param names to properties (msg/default) - */ - protected function getCustomFilters() { - if ( $this->customFilters === null ) { - $this->customFilters = []; - Hooks::run( 'ChangesListSpecialPageFilters', [ $this, &$this->customFilters ], '1.29' ); - } - - return $this->customFilters; - } - /** * Fetch values for a FormOptions object from the WebRequest associated with this instance. * diff --git a/includes/specials/SpecialRecentchanges.php b/includes/specials/SpecialRecentchanges.php index 983f74cd82..3e8bf1202c 100644 --- a/includes/specials/SpecialRecentchanges.php +++ b/includes/specials/SpecialRecentchanges.php @@ -225,20 +225,6 @@ class SpecialRecentChanges extends ChangesListSpecialPage { } } - /** - * Get all custom filters - * - * @return array Map of filter URL param names to properties (msg/default) - */ - protected function getCustomFilters() { - if ( $this->customFilters === null ) { - $this->customFilters = parent::getCustomFilters(); - Hooks::run( 'SpecialRecentChangesFilters', [ $this, &$this->customFilters ], '1.23' ); - } - - return $this->customFilters; - } - /** * Process $par and put options found in $opts. Used when including the page. * diff --git a/includes/specials/SpecialWatchlist.php b/includes/specials/SpecialWatchlist.php index 908183d25a..432cfcc2f9 100644 --- a/includes/specials/SpecialWatchlist.php +++ b/includes/specials/SpecialWatchlist.php @@ -289,20 +289,6 @@ class SpecialWatchlist extends ChangesListSpecialPage { } } - /** - * Get all custom filters - * - * @return array Map of filter URL param names to properties (msg/default) - */ - protected function getCustomFilters() { - if ( $this->customFilters === null ) { - $this->customFilters = parent::getCustomFilters(); - Hooks::run( 'SpecialWatchlistFilters', [ $this, &$this->customFilters ], '1.23' ); - } - - return $this->customFilters; - } - /** * Fetch values for a FormOptions object from the WebRequest associated with this instance. * diff --git a/tests/phpunit/includes/specialpage/ChangesListSpecialPageTest.php b/tests/phpunit/includes/specialpage/ChangesListSpecialPageTest.php index aeaa1aee9e..19a1875d58 100644 --- a/tests/phpunit/includes/specialpage/ChangesListSpecialPageTest.php +++ b/tests/phpunit/includes/specialpage/ChangesListSpecialPageTest.php @@ -673,43 +673,6 @@ class ChangesListSpecialPageTest extends AbstractChangesListSpecialPageTestCase return $now - $days * $secondsPerDay; } - public function testGetFilterGroupDefinitionFromLegacyCustomFilters() { - $customFilters = [ - 'hidefoo' => [ - 'msg' => 'showhidefoo', - 'default' => true, - ], - - 'hidebar' => [ - 'msg' => 'showhidebar', - 'default' => false, - ], - ]; - - $this->assertEquals( - [ - 'name' => 'unstructured', - 'class' => ChangesListBooleanFilterGroup::class, - 'priority' => -1, - 'filters' => [ - [ - 'name' => 'hidefoo', - 'showHide' => 'showhidefoo', - 'default' => true, - ], - [ - 'name' => 'hidebar', - 'showHide' => 'showhidebar', - 'default' => false, - ] - ], - ], - $this->changesListSpecialPage->getFilterGroupDefinitionFromLegacyCustomFilters( - $customFilters - ) - ); - } - public function testGetStructuredFilterJsData() { $this->changesListSpecialPage->filterGroups = []; -- 2.20.1