Provide an opt-out preference for New Filters for RecentChanges
authorJames D. Forrester <jforrester@wikimedia.org>
Wed, 23 Aug 2017 21:30:20 +0000 (14:30 -0700)
committerCatrope <roan@wikimedia.org>
Mon, 11 Sep 2017 22:56:00 +0000 (22:56 +0000)
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
includes/Preferences.php
includes/specialpage/ChangesListSpecialPage.php
includes/specials/SpecialWatchlist.php
languages/i18n/en.json
languages/i18n/qqq.json

index cf8e089..86b1bdc 100644 (file)
@@ -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;
 
index c64e8a8..c29c4b9 100644 (file)
@@ -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',
+                       ];
+               }
        }
 
        /**
index 5f54404..d498195 100644 (file)
@@ -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();
index 7049744..ec64869 100644 (file)
@@ -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' );
        }
 
        /**
index 4b01132..badf43d 100644 (file)
        "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 <strong>bold</strong>, 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 <strong>$3, $4</strong> (up to <strong>$1</strong> shown).",
        "rclistfromreset": "Reset date selection",
        "rclistfrom": "Show new changes starting from $2, $3",
index 897728e..525ebe5 100644 (file)
        "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}}.",