r94416 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r94415‎ | r94416 | r94417 >
Date:15:39, 13 August 2011
Author:reedy
Status:ok
Tags:
Comment:
* (bug 26885) Allow show/hide of account blocks, temporary blocks and single IP blocks for list=blocks

Patch by John DuHart

Minor extras:
* Minor style tweak
* Add new error to getPossibleErrors
* Reused $p for module prefix
Modified paths:
  • /trunk/phase3/RELEASE-NOTES-1.19 (modified) (history)
  • /trunk/phase3/includes/api/ApiQueryBlocks.php (modified) (history)

Diff [purge]

Index: trunk/phase3/RELEASE-NOTES-1.19
@@ -54,6 +54,8 @@
5555 a best effort language name translation. Use CLDR extension for best result.
5656 * (bug 30230) action=expandtemplates should not silently override invalid title inputs
5757 * (bug 18634) Create API to fetch MediaWiki's language fallback tree structure
 58+* (bug 26885) Allow show/hide of account blocks, temporary blocks and single IP blocks
 59+ for list=blocks
5860
5961 === Languages updated in 1.19 ===
6062
Index: trunk/phase3/includes/api/ApiQueryBlocks.php
@@ -114,6 +114,28 @@
115115 ) );
116116 }
117117
 118+ if ( !is_null( $params['show'] ) ) {
 119+ $show = array_flip( $params['show'] );
 120+
 121+ /* Check for conflicting parameters. */
 122+ if ( ( isset ( $show['account'] ) && isset ( $show['!account'] ) )
 123+ || ( isset ( $show['ip'] ) && isset ( $show['!ip'] ) )
 124+ || ( isset ( $show['range'] ) && isset ( $show['!range'] ) )
 125+ || ( isset ( $show['temp'] ) && isset ( $show['!temp'] ) )
 126+ ) {
 127+ $this->dieUsageMsg( 'show' );
 128+ }
 129+
 130+ $this->addWhereIf( 'ipb_user = 0', isset( $show['!account'] ) );
 131+ $this->addWhereIf( 'ipb_user != 0', isset( $show['account'] ) );
 132+ $this->addWhereIf( 'ipb_user != 0 OR ipb_range_end > ipb_range_start', isset( $show['!ip'] ) );
 133+ $this->addWhereIf( 'ipb_user = 0 AND ipb_range_end = ipb_range_start', isset( $show['ip'] ) );
 134+ $this->addWhereIf( "ipb_expiry = 'infinity'", isset( $show['!temp'] ) );
 135+ $this->addWhereIf( "ipb_expiry != 'infinity'", isset( $show['temp'] ) );
 136+ $this->addWhereIf( "ipb_range_end = ipb_range_start", isset( $show['!range'] ) );
 137+ $this->addWhereIf( "ipb_range_end > ipb_range_start", isset( $show['range'] ) );
 138+ }
 139+
118140 if ( !$wgUser->isAllowed( 'hideuser' ) ) {
119141 $this->addWhereFld( 'ipb_deleted', 0 );
120142 }
@@ -252,15 +274,29 @@
253275 'flags'
254276 ),
255277 ApiBase::PARAM_ISMULTI => true
256 - )
 278+ ),
 279+ 'show' => array(
 280+ ApiBase::PARAM_TYPE => array(
 281+ 'account',
 282+ '!account',
 283+ 'temp',
 284+ '!temp',
 285+ 'ip',
 286+ '!ip',
 287+ 'range',
 288+ '!range',
 289+ ),
 290+ ApiBase::PARAM_ISMULTI => true
 291+ ),
257292 );
258293 }
259294
260295 public function getParamDescription() {
 296+ $p = $this->getModulePrefix();
261297 return array(
262298 'start' => 'The timestamp to start enumerating from',
263299 'end' => 'The timestamp to stop enumerating at',
264 - 'dir' => $this->getDirectionDescription( $this->getModulePrefix() ),
 300+ 'dir' => $this->getDirectionDescription( $p ),
265301 'ids' => 'Pipe-separated list of block IDs to list (optional)',
266302 'users' => 'Pipe-separated list of users to search for (optional)',
267303 'ip' => array( 'Get all blocks applying to this IP or CIDR range, including range blocks.',
@@ -279,6 +315,10 @@
280316 ' range - Adds the range of IPs affected by the block',
281317 ' flags - Tags the ban with (autoblock, anononly, etc)',
282318 ),
 319+ 'show' => array(
 320+ 'Show only items that meet this criteria.',
 321+ "For example, to see only indefinite blocks on IPs, set {$p}show=ip|!temp"
 322+ ),
283323 );
284324 }
285325
@@ -292,6 +332,7 @@
293333 array( 'code' => 'cidrtoobroad', 'info' => 'CIDR ranges broader than /16 are not accepted' ),
294334 array( 'code' => 'param_user', 'info' => 'User parameter may not be empty' ),
295335 array( 'code' => 'param_user', 'info' => 'User name user is not valid' ),
 336+ array( 'show' ),
296337 ) );
297338 }
298339

Status & tagging log