jenkins-bot has submitted this change and it was merged.

Change subject: Rename Watchlist request parameters for consistency with RC's 
ones
......................................................................


Rename Watchlist request parameters for consistency with RC's ones

This is necessary for us to be later able to have them be inherited
(and use FormOptions). Old parameters (and thus old URIs) will continue
to work (but will never be used in newly generated links).

However, this breaks compatibility of the SpecialWatchlistQuery hook, as
the keys of the array it accepts as the last parameter have changed due to
the renaming. This could be worked around easily if we deem it worth
worrying about.

Change-Id: Ia6b2047006c86256ec22d7eda92a23be2058f1a3
---
M RELEASE-NOTES-1.23
M includes/specials/SpecialWatchlist.php
2 files changed, 65 insertions(+), 25 deletions(-)

Approvals:
  Ori.livneh: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/RELEASE-NOTES-1.23 b/RELEASE-NOTES-1.23
index 6b665bb..e017a62 100644
--- a/RELEASE-NOTES-1.23
+++ b/RELEASE-NOTES-1.23
@@ -157,6 +157,12 @@
 * A page_links_updated field has been added to the page table.
 * SpecialPage::getTitle has been deprecated in favor of
   SpecialPage::getPageTitle.
+* BREAKING CHANGE: A potentially backwards-incompatible change has been made
+  to the 'SpecialWatchlistQuery' hook's last parameter (array $values) to make
+  the hook more consistent with the 'SpecialRecentChangesQuery' one:
+** Several array keys have been renamed: hideMinor → hideminor,
+   hideBots → hidebots, hideAnons → hideanons, hideLiu → hideliu,
+   hidePatrolled → hidepatrolled, hideOwn → hidemyself.
 
 ==== Removed classes ====
 * TitleDependency (unused)
diff --git a/includes/specials/SpecialWatchlist.php 
b/includes/specials/SpecialWatchlist.php
index a680bac..5a77b48 100644
--- a/includes/specials/SpecialWatchlist.php
+++ b/includes/specials/SpecialWatchlist.php
@@ -35,11 +35,45 @@
        }
 
        /**
+        * Map old pre-1.23 request parameters Watchlist used to use (different 
from Recentchanges' ones)
+        * to the current ones.
+        *
+        * This creates derivative context and request, pokes with request's 
parameters, and sets them as
+        * the context for this class instance, mapping old keys to new ones 
completely transparently (as
+        * long as nothing tries to access the globals instead of current 
context).
+        */
+       private function mapCompatibilityRequestParameters() {
+               static $map = array(
+                       'hideMinor' => 'hideminor',
+                       'hideBots' => 'hidebots',
+                       'hideAnons' => 'hideanons',
+                       'hideLiu' => 'hideliu',
+                       'hidePatrolled' => 'hidepatrolled',
+                       'hideOwn' => 'hidemyself',
+               );
+
+               $params = $this->getRequest()->getValues();
+               foreach ( $map as $from => $to ) {
+                       if ( isset( $params[$from] ) ) {
+                               $params[$to] = $params[$from];
+                               unset( $params[$from] );
+                       }
+               }
+
+               $context = new DerivativeContext( $this->getContext() );
+               $request = new DerivativeRequest( $context->getRequest(), 
$params );
+               $context->setRequest( $request );
+               $this->setContext( $context );
+       }
+
+       /**
         * Execute
         * @param $par Parameter passed to the page
         */
        function execute( $par ) {
                global $wgRCShowWatchingUsers, $wgEnotifWatchlist, 
$wgShowUpdatedMarker;
+
+               $this->mapCompatibilityRequestParameters();
 
                $user = $this->getUser();
                $output = $this->getOutput();
@@ -96,12 +130,12 @@
                // @todo use FormOptions!
                $defaults = array(
                /* float */ 'days' => floatval( $user->getOption( 
'watchlistdays' ) ),
-               /* bool  */ 'hideMinor' => (int)$user->getBoolOption( 
'watchlisthideminor' ),
-               /* bool  */ 'hideBots' => (int)$user->getBoolOption( 
'watchlisthidebots' ),
-               /* bool  */ 'hideAnons' => (int)$user->getBoolOption( 
'watchlisthideanons' ),
-               /* bool  */ 'hideLiu' => (int)$user->getBoolOption( 
'watchlisthideliu' ),
-               /* bool  */ 'hidePatrolled' => (int)$user->getBoolOption( 
'watchlisthidepatrolled' ),
-               /* bool  */ 'hideOwn' => (int)$user->getBoolOption( 
'watchlisthideown' ),
+               /* bool  */ 'hideminor' => (int)$user->getBoolOption( 
'watchlisthideminor' ),
+               /* bool  */ 'hidebots' => (int)$user->getBoolOption( 
'watchlisthidebots' ),
+               /* bool  */ 'hideanons' => (int)$user->getBoolOption( 
'watchlisthideanons' ),
+               /* bool  */ 'hideliu' => (int)$user->getBoolOption( 
'watchlisthideliu' ),
+               /* bool  */ 'hidepatrolled' => (int)$user->getBoolOption( 
'watchlisthidepatrolled' ),
+               /* bool  */ 'hidemyself' => (int)$user->getBoolOption( 
'watchlisthideown' ),
                /* bool  */ 'extended' => (int)$user->getBoolOption( 
'extendwatchlist' ),
                /* ?     */ 'namespace' => '', //means all
                /* ?     */ 'invert' => false,
@@ -117,12 +151,12 @@
                # other default values if these don't exist
                $values = array();
                $values['days'] = floatval( $request->getVal( 'days', 
$defaults['days'] ) );
-               $values['hideMinor'] = (int)$request->getBool( 'hideMinor', 
$defaults['hideMinor'] );
-               $values['hideBots'] = (int)$request->getBool( 'hideBots', 
$defaults['hideBots'] );
-               $values['hideAnons'] = (int)$request->getBool( 'hideAnons', 
$defaults['hideAnons'] );
-               $values['hideLiu'] = (int)$request->getBool( 'hideLiu', 
$defaults['hideLiu'] );
-               $values['hideOwn'] = (int)$request->getBool( 'hideOwn', 
$defaults['hideOwn'] );
-               $values['hidePatrolled'] = (int)$request->getBool( 
'hidePatrolled', $defaults['hidePatrolled'] );
+               $values['hideminor'] = (int)$request->getBool( 'hideminor', 
$defaults['hideminor'] );
+               $values['hidebots'] = (int)$request->getBool( 'hidebots', 
$defaults['hidebots'] );
+               $values['hideanons'] = (int)$request->getBool( 'hideanons', 
$defaults['hideanons'] );
+               $values['hideliu'] = (int)$request->getBool( 'hideliu', 
$defaults['hideliu'] );
+               $values['hidemyself'] = (int)$request->getBool( 'hidemyself', 
$defaults['hidemyself'] );
+               $values['hidepatrolled'] = (int)$request->getBool( 
'hidepatrolled', $defaults['hidepatrolled'] );
                $values['extended'] = (int)$request->getBool( 'extended', 
$defaults['extended'] );
                foreach ( $this->customFilters as $key => $params ) {
                        $values[$key] = (int)$request->getBool( $key, 
$defaults[$key] );
@@ -175,22 +209,22 @@
                }
 
                # Toggles
-               if ( $values['hideOwn'] ) {
+               if ( $values['hidemyself'] ) {
                        $conds[] = 'rc_user != ' . $user->getId();
                }
-               if ( $values['hideBots'] ) {
+               if ( $values['hidebots'] ) {
                        $conds[] = 'rc_bot = 0';
                }
-               if ( $values['hideMinor'] ) {
+               if ( $values['hideminor'] ) {
                        $conds[] = 'rc_minor = 0';
                }
-               if ( $values['hideLiu'] ) {
+               if ( $values['hideliu'] ) {
                        $conds[] = 'rc_user = 0';
                }
-               if ( $values['hideAnons'] ) {
+               if ( $values['hideanons'] ) {
                        $conds[] = 'rc_user != 0';
                }
-               if ( $user->useRCPatrol() && $values['hidePatrolled'] ) {
+               if ( $user->useRCPatrol() && $values['hidepatrolled'] ) {
                        $conds[] = 'rc_patrolled != 1';
                }
                if ( $nameSpaceClause ) {
@@ -312,19 +346,19 @@
 
                # Spit out some control panel links
                $filters = array(
-                       'hideMinor' => 'rcshowhideminor',
-                       'hideBots' => 'rcshowhidebots',
-                       'hideAnons' => 'rcshowhideanons',
-                       'hideLiu' => 'rcshowhideliu',
-                       'hideOwn' => 'rcshowhidemine',
-                       'hidePatrolled' => 'rcshowhidepatr'
+                       'hideminor' => 'rcshowhideminor',
+                       'hidebots' => 'rcshowhidebots',
+                       'hideanons' => 'rcshowhideanons',
+                       'hideliu' => 'rcshowhideliu',
+                       'hidemyself' => 'rcshowhidemine',
+                       'hidepatrolled' => 'rcshowhidepatr'
                );
                foreach ( $this->customFilters as $key => $params ) {
                        $filters[$key] = $params['msg'];
                }
                // Disable some if needed
                if ( !$user->useNPPatrol() ) {
-                       unset( $filters['hidePatrolled'] );
+                       unset( $filters['hidepatrolled'] );
                }
 
                $links = array();

-- 
To view, visit https://gerrit.wikimedia.org/r/89380
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Ia6b2047006c86256ec22d7eda92a23be2058f1a3
Gerrit-PatchSet: 15
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Bartosz Dziewoński <[email protected]>
Gerrit-Reviewer: Anomie <[email protected]>
Gerrit-Reviewer: Aude <[email protected]>
Gerrit-Reviewer: Bartosz Dziewoński <[email protected]>
Gerrit-Reviewer: Krinkle <[email protected]>
Gerrit-Reviewer: Ori.livneh <[email protected]>
Gerrit-Reviewer: jenkins-bot

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to