From 63601400e476c6cf43d985f3e7b9864681695ed4 Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Fri, 18 Jan 2013 16:46:04 +0100 Subject: Update to MediaWiki 1.20.2 this update includes: * adjusted Arch Linux skin * updated FluxBBAuthPlugin * patch for https://bugzilla.wikimedia.org/show_bug.cgi?id=44024 --- includes/api/ApiQueryBlocks.php | 87 +++++++++++++++++++++++++++++++++++------ 1 file changed, 75 insertions(+), 12 deletions(-) (limited to 'includes/api/ApiQueryBlocks.php') diff --git a/includes/api/ApiQueryBlocks.php b/includes/api/ApiQueryBlocks.php index bebb5a7d..96b86962 100644 --- a/includes/api/ApiQueryBlocks.php +++ b/includes/api/ApiQueryBlocks.php @@ -4,7 +4,7 @@ * * Created on Sep 10, 2007 * - * Copyright © 2007 Roan Kattouw .@gmail.com + * Copyright © 2007 Roan Kattouw ".@gmail.com" * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -77,6 +77,9 @@ class ApiQueryBlocks extends ApiQueryBase { $this->addOption( 'LIMIT', $params['limit'] + 1 ); $this->addTimestampWhereRange( 'ipb_timestamp', $params['dir'], $params['start'], $params['end'] ); + + $db = $this->getDB(); + if ( isset( $params['ids'] ) ) { $this->addWhereFld( 'ipb_id', $params['ids'] ); } @@ -87,7 +90,6 @@ class ApiQueryBlocks extends ApiQueryBase { $this->addWhereFld( 'ipb_address', $this->usernames ); $this->addWhereFld( 'ipb_auto', 0 ); } - $db = $this->getDB(); if ( isset( $params['ip'] ) ) { list( $ip, $range ) = IP::parseCIDR( $params['ip'] ); if ( $ip && $range ) { @@ -101,10 +103,15 @@ class ApiQueryBlocks extends ApiQueryBase { } $prefix = substr( $lower, 0, 4 ); + # Fairly hard to make a malicious SQL statement out of hex characters, + # but it is good practice to add quotes + $lower = $db->addQuotes( $lower ); + $upper = $db->addQuotes( $upper ); + $this->addWhere( array( 'ipb_range_start' . $db->buildLike( $prefix, $db->anyString() ), - "ipb_range_start <= '$lower'", - "ipb_range_end >= '$upper'", + 'ipb_range_start <= ' . $lower, + 'ipb_range_end >= ' . $upper, 'ipb_auto' => 0 ) ); } @@ -292,8 +299,8 @@ class ApiQueryBlocks extends ApiQueryBase { 'start' => 'The timestamp to start enumerating from', 'end' => 'The timestamp to stop enumerating at', 'dir' => $this->getDirectionDescription( $p ), - 'ids' => 'Pipe-separated list of block IDs to list (optional)', - 'users' => 'Pipe-separated list of users to search for (optional)', + 'ids' => 'List of block IDs to list (optional)', + 'users' => 'List of users to search for (optional)', 'ip' => array( 'Get all blocks applying to this IP or CIDR range, including range blocks.', 'Cannot be used together with bkusers. CIDR ranges broader than /16 are not accepted' ), 'limit' => 'The maximum amount of blocks to list', @@ -317,18 +324,74 @@ class ApiQueryBlocks extends ApiQueryBase { ); } + public function getResultProperties() { + return array( + 'id' => array( + 'id' => 'integer' + ), + 'user' => array( + 'user' => array( + ApiBase::PROP_TYPE => 'string', + ApiBase::PROP_NULLABLE => true + ) + ), + 'userid' => array( + 'userid' => array( + ApiBase::PROP_TYPE => 'integer', + ApiBase::PROP_NULLABLE => true + ) + ), + 'by' => array( + 'by' => 'string' + ), + 'byid' => array( + 'byid' => 'integer' + ), + 'timestamp' => array( + 'timestamp' => 'timestamp' + ), + 'expiry' => array( + 'expiry' => 'timestamp' + ), + 'reason' => array( + 'reason' => 'string' + ), + 'range' => array( + 'rangestart' => array( + ApiBase::PROP_TYPE => 'string', + ApiBase::PROP_NULLABLE => true + ), + 'rangeend' => array( + ApiBase::PROP_TYPE => 'string', + ApiBase::PROP_NULLABLE => true + ) + ), + 'flags' => array( + 'automatic' => 'boolean', + 'anononly' => 'boolean', + 'nocreate' => 'boolean', + 'autoblock' => 'boolean', + 'noemail' => 'boolean', + 'hidden' => 'boolean', + 'allowusertalk' => 'boolean' + ) + ); + } + public function getDescription() { return 'List all blocked users and IP addresses'; } public function getPossibleErrors() { - return array_merge( parent::getPossibleErrors(), array( + return array_merge( parent::getPossibleErrors(), $this->getRequireOnlyOneParameterErrorMessages( array( 'users', 'ip' ) ), - array( 'code' => 'cidrtoobroad', 'info' => 'CIDR ranges broader than /16 are not accepted' ), - array( 'code' => 'param_user', 'info' => 'User parameter may not be empty' ), - array( 'code' => 'param_user', 'info' => 'User name user is not valid' ), - array( 'show' ), - ) ); + array( + array( 'code' => 'cidrtoobroad', 'info' => 'CIDR ranges broader than /16 are not accepted' ), + array( 'code' => 'param_user', 'info' => 'User parameter may not be empty' ), + array( 'code' => 'param_user', 'info' => 'User name user is not valid' ), + array( 'show' ), + ) + ); } public function getExamples() { -- cgit v1.2.2