From c12b2419298bf72c569834d11de85aa3f376fac9 Mon Sep 17 00:00:00 2001 From: "James D. Forrester" Date: Wed, 23 Aug 2017 14:30:20 -0700 Subject: [PATCH] Provide an opt-out preference for New Filters for RecentChanges Currently this is disabled by default. On wikis with the BetaFeatures and WikimediaMessages extensions installed, this preference is set (if the $wgEnableRcFiltersBetaFeature flag is set) via BetaFeatures. This change lets users on normal wikis use these too, and lets BetaFeatures-capable wikis "graduate" the feature to be provided to all users by default. Bug: T168376 Change-Id: I3c75f9f2f6287414bf330f116d959d078250392d --- includes/DefaultSettings.php | 19 +++++++++++++++ includes/Preferences.php | 9 +++++++ .../specialpage/ChangesListSpecialPage.php | 24 ++++++++++++++++++- includes/specials/SpecialWatchlist.php | 12 +++++++--- languages/i18n/en.json | 2 ++ languages/i18n/qqq.json | 2 ++ 6 files changed, 64 insertions(+), 4 deletions(-) diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index cf8e089bee..86b1bdca55 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -4920,6 +4920,7 @@ $wgDefaultUserOptions = [ 'previewontop' => 1, 'rcdays' => 7, 'rcenhancedfilters' => 0, + 'rcenhancedfilters-disable' => 0, 'rclimit' => 50, 'rows' => 25, // @deprecated since 1.29 No longer used in core 'showhiddencats' => 0, @@ -6829,19 +6830,37 @@ $wgRCWatchCategoryMembership = false; */ $wgUseRCPatrol = true; +/** + * Whether a preference is displayed for structured change filters. + * If false, no preference is displayed and structured change filters are disabled. + * If true, structured change filters are *enabled* by default, and a preference is displayed + * that lets users disable them. + * + * Temporary variable during development and will be removed. + * + * @since 1.30 + */ +$wgStructuredChangeFiltersShowPreference = false; + /** * Whether to show the new experimental views (like namespaces, tags, and users) in * RecentChanges filters + * + * Temporary variable during development and will be removed. */ $wgStructuredChangeFiltersEnableExperimentalViews = false; /** * Whether to allow users to use the experimental live update feature in the new RecentChanges UI + * + * Temporary variable during development and will be removed. */ $wgStructuredChangeFiltersEnableLiveUpdate = false; /** * Whether to enable RCFilters app on Special:Watchlist + * + * Temporary variable during development and will be removed. */ $wgStructuredChangeFiltersOnWatchlist = false; diff --git a/includes/Preferences.php b/includes/Preferences.php index c64e8a8ae1..c29c4b9c85 100644 --- a/includes/Preferences.php +++ b/includes/Preferences.php @@ -958,6 +958,15 @@ class Preferences { 'label-message' => 'tog-shownumberswatching', ]; } + + if ( $config->get( 'StructuredChangeFiltersShowPreference' ) ) { + $defaultPreferences['rcenhancedfilters-disable'] = [ + 'type' => 'toggle', + 'section' => 'rc/advancedrc', + 'label-message' => 'rcfilters-preference-label', + 'help-message' => 'rcfilters-preference-help', + ]; + } } /** diff --git a/includes/specialpage/ChangesListSpecialPage.php b/includes/specialpage/ChangesListSpecialPage.php index 5f544042f9..d498195e6c 100644 --- a/includes/specialpage/ChangesListSpecialPage.php +++ b/includes/specialpage/ChangesListSpecialPage.php @@ -1537,7 +1537,29 @@ abstract class ChangesListSpecialPage extends SpecialPage { * @return bool */ public function isStructuredFilterUiEnabled() { - return $this->getUser()->getOption( 'rcenhancedfilters' ); + if ( $this->getRequest()->getBool( 'rcfilters' ) ) { + return true; + } + + if ( $this->getConfig()->get( 'StructuredChangeFiltersShowPreference' ) ) { + return !$this->getUser()->getOption( 'rcenhancedfilters-disable' ); + } else { + return $this->getUser()->getOption( 'rcenhancedfilters' ); + } + } + + /** + * Check whether the structured filter UI is enabled by default (regardless of + * this particular user's setting) + * + * @return bool + */ + public function isStructuredFilterUiEnabledByDefault() { + if ( $this->getConfig()->get( 'StructuredChangeFiltersShowPreference' ) ) { + return !$this->getUser()->getDefaultOption( 'rcenhancedfilters-disable' ); + } else { + return $this->getUser()->getDefaultOption( 'rcenhancedfilters' ); + } } abstract function getDefaultLimit(); diff --git a/includes/specials/SpecialWatchlist.php b/includes/specials/SpecialWatchlist.php index 7049744224..ec648690f4 100644 --- a/includes/specials/SpecialWatchlist.php +++ b/includes/specials/SpecialWatchlist.php @@ -112,9 +112,15 @@ class SpecialWatchlist extends ChangesListSpecialPage { } public function isStructuredFilterUiEnabled() { - return parent::isStructuredFilterUiEnabled() - && ( $this->getConfig()->get( 'StructuredChangeFiltersOnWatchlist' ) - || $this->getRequest()->getBool( 'rcfilters' ) ); + return $this->getRequest()->getBool( 'rcfilters' ) || ( + $this->getConfig()->get( 'StructuredChangeFiltersOnWatchlist' ) && + $this->getUser()->getOption( 'rcenhancedfilters' ) + ); + } + + public function isStructuredFilterUiEnabledByDefault() { + return $this->getConfig()->get( 'StructuredChangeFiltersOnWatchlist' ) && + $this->getUser()->getDefaultOption( 'rcenhancedfilters' ); } /** diff --git a/languages/i18n/en.json b/languages/i18n/en.json index 4b01132e37..badf43dea1 100644 --- a/languages/i18n/en.json +++ b/languages/i18n/en.json @@ -1471,6 +1471,8 @@ "rcfilters-watchlist-markseen-button": "Mark all changes as seen", "rcfilters-watchlist-edit-watchlist-button": "Edit your list of watched pages", "rcfilters-watchlist-showupdated": "Changes to pages you haven't visited since the changes occurred are in bold, with solid markers.", + "rcfilters-preference-label": "Hide the improved version of Recent Changes", + "rcfilters-preference-help": "Rolls back the 2017 interface redesign and all tools added then and since.", "rcnotefrom": "Below {{PLURAL:$5|is the change|are the changes}} since $3, $4 (up to $1 shown).", "rclistfromreset": "Reset date selection", "rclistfrom": "Show new changes starting from $2, $3", diff --git a/languages/i18n/qqq.json b/languages/i18n/qqq.json index 897728e0f0..525ebe50a1 100644 --- a/languages/i18n/qqq.json +++ b/languages/i18n/qqq.json @@ -1662,6 +1662,8 @@ "rcfilters-watchlist-markseen-button": "Label for the button to mark all changes as seen on [[Special:Watchlist]] when using the structured filters interface.", "rcfilters-watchlist-edit-watchlist-button": "Label for the button to edit the watched pages on [[Special:Watchlist]] when using the structured filters interface.\n\nCf. {{msg-mw|watchlisttools-edit}}.", "rcfilters-watchlist-showupdated": "Message at the top of [[Special:Watchlist]] when the Structured filters are enabled that describes what unseen changes look like.\n\nCf. {{msg-mw|wlheader-showupdated}}", + "rcfilters-preference-label": "Option in RecentChanges tab of [[Special:Preferences]].", + "rcfilters-preference-help": "Explanation for the option in the RecentChanges tab of [[Special:Preferences]].", "rcnotefrom": "This message is displayed at [[Special:RecentChanges]] when viewing recentchanges from some specific time.\n\nThe corresponding message is {{msg-mw|Rclistfrom}}.\n\nParameters:\n* $1 - the maximum number of changes that are displayed\n* $2 - (Optional) a date and time\n* $3 - a date\n* $4 - a time\n* $5 - Number of changes are displayed, for use with PLURAL", "rclistfromreset": "Used on [[Special:RecentChanges]] to reset a selection of a certain date range.", "rclistfrom": "Used on [[Special:RecentChanges]]. Parameters:\n* $1 - (Currently not use) date and time. The date and the time adds to the rclistfrom description.\n* $2 - time. The time adds to the rclistfrom link description (with split of date and time).\n* $3 - date. The date adds to the rclistfrom link description (with split of date and time).\n\nThe corresponding message is {{msg-mw|Rcnotefrom}}.", -- 2.20.1