Merge "RC/Watchlist: Filter out parameters that cannot be displayed"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Wed, 7 Dec 2016 01:07:58 +0000 (01:07 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Wed, 7 Dec 2016 01:07:58 +0000 (01:07 +0000)
includes/specialpage/ChangesListSpecialPage.php
includes/specials/SpecialRecentchanges.php
includes/specials/SpecialWatchlist.php

index cb13840..9e3e3df 100644 (file)
@@ -495,4 +495,23 @@ abstract class ChangesListSpecialPage extends SpecialPage {
        protected function getGroupName() {
                return 'changes';
        }
+
+       /**
+        * Get filters that can be rendered.
+        *
+        * Filters with 'msg' => false can be used to filter data but won't
+        * be presented as show/hide toggles in the UI. They are not returned
+        * by this function.
+        *
+        * @param array $allFilters Map of filter URL param names to properties (msg/default)
+        * @return array Map of filter URL param names to properties (msg/default)
+        */
+       protected function getRenderableCustomFilters( $allFilters ) {
+               return array_filter(
+                       $allFilters,
+                       function( $filter ) {
+                               return isset( $filter['msg'] ) && ( $filter['msg'] !== false );
+                       }
+               );
+       }
 }
index cd3299c..4569dd2 100644 (file)
@@ -95,7 +95,7 @@ class SpecialRecentChanges extends ChangesListSpecialPage {
        }
 
        /**
-        * Get custom show/hide filters
+        * Get all custom filters
         *
         * @return array Map of filter URL param names to properties (msg/default)
         */
@@ -747,9 +747,10 @@ class SpecialRecentChanges extends ChangesListSpecialPage {
 
                $showhide = [ 'show', 'hide' ];
 
-               foreach ( $this->getCustomFilters() as $key => $params ) {
+               foreach ( $this->getRenderableCustomFilters( $this->getCustomFilters() ) as $key => $params ) {
                        $filters[$key] = $params['msg'];
                }
+
                // Disable some if needed
                if ( !$user->useRCPatrol() ) {
                        unset( $filters['hidepatrolled'] );
index 4824961..55400d3 100644 (file)
@@ -130,7 +130,7 @@ class SpecialWatchlist extends ChangesListSpecialPage {
        }
 
        /**
-        * Get custom show/hide filters
+        * Get all custom filters
         *
         * @return array Map of filter URL param names to properties (msg/default)
         */
@@ -465,9 +465,10 @@ class SpecialWatchlist extends ChangesListSpecialPage {
                        $filters['hidecategorization'] = 'wlshowhidecategorization';
                }
 
-               foreach ( $this->getCustomFilters() as $key => $params ) {
+               foreach ( $this->getRenderableCustomFilters( $this->getCustomFilters() ) as $key => $params ) {
                        $filters[$key] = $params['msg'];
                }
+
                // Disable some if needed
                if ( !$user->useRCPatrol() ) {
                        unset( $filters['hidepatrolled'] );