From: Stephane Bisson Date: Wed, 23 Nov 2016 19:39:23 +0000 (-0500) Subject: RC/Watchlist: Filter out parameters that cannot be displayed X-Git-Tag: 1.31.0-rc.0~4650^2 X-Git-Url: http://git.cyclocoop.org/%22%20.%20generer_url_ecrire%28%22lang_raccourcis%22%2C%22module=%24nom_module%22%29%20.%20%22?a=commitdiff_plain;h=a2dd90eb4a2bd6db02d5952419e99c864a77a02b;p=lhc%2Fweb%2Fwiklou.git RC/Watchlist: Filter out parameters that cannot be displayed Some parameters added by the ORES extension work with the URL and the new ERI UI but not with the old toggle (hide*) filter UI. Specifying 'msg' => false when adding them from the hook registers them correctly but they won't be displayed. Bug: T149853 Change-Id: If47842f3d91c5999a7c5bf25666b967e9b30a6d7 --- diff --git a/includes/specialpage/ChangesListSpecialPage.php b/includes/specialpage/ChangesListSpecialPage.php index cb13840528..9e3e3df399 100644 --- a/includes/specialpage/ChangesListSpecialPage.php +++ b/includes/specialpage/ChangesListSpecialPage.php @@ -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 ); + } + ); + } } diff --git a/includes/specials/SpecialRecentchanges.php b/includes/specials/SpecialRecentchanges.php index cd3299c210..4569dd2601 100644 --- a/includes/specials/SpecialRecentchanges.php +++ b/includes/specials/SpecialRecentchanges.php @@ -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'] ); diff --git a/includes/specials/SpecialWatchlist.php b/includes/specials/SpecialWatchlist.php index 4824961c70..55400d3cc9 100644 --- a/includes/specials/SpecialWatchlist.php +++ b/includes/specials/SpecialWatchlist.php @@ -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'] );