Merge "hooks: Drop Special{Watchlist|RecentChanges}Filters, deprecated in 1.23"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Thu, 13 Sep 2018 00:56:17 +0000 (00:56 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Thu, 13 Sep 2018 00:56:17 +0000 (00:56 +0000)
RELEASE-NOTES-1.32
docs/hooks.txt
includes/changes/ChangesListBooleanFilter.php
includes/specialpage/ChangesListSpecialPage.php
includes/specials/SpecialRecentchanges.php
includes/specials/SpecialWatchlist.php
tests/phpunit/includes/specialpage/ChangesListSpecialPageTest.php

index 041b3d7..52dbbff 100644 (file)
@@ -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
index cce50e0..9a53ccf 100644 (file)
@@ -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.
index fc37882..c781d71 100644 (file)
@@ -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
         *
index caa039b..43b4e98 100644 (file)
@@ -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.
         *
index 983f74c..3e8bf12 100644 (file)
@@ -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.
         *
index 908183d..432cfcc 100644 (file)
@@ -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.
         *
index aeaa1ae..19a1875 100644 (file)
@@ -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 = [];