API: Fixed handling of usernames containing spaces in list=block
This commit is contained in:
parent
dc89b44191
commit
cb77d12c70
2 changed files with 23 additions and 1 deletions
|
|
@ -266,6 +266,7 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN
|
|||
* action=login now returns the correct waiting time in the details property
|
||||
* (bug 13792) Broken titles are now silently skipped in search results.
|
||||
* (bug 13819) exturlusage paging skipped an item
|
||||
* Fixed handling of usernames containing spaces in list=block
|
||||
|
||||
=== Languages updated in 1.13 ===
|
||||
|
||||
|
|
|
|||
|
|
@ -34,6 +34,8 @@ if (!defined('MEDIAWIKI')) {
|
|||
* @addtogroup API
|
||||
*/
|
||||
class ApiQueryBlocks extends ApiQueryBase {
|
||||
|
||||
var $users;
|
||||
|
||||
public function __construct($query, $moduleName) {
|
||||
parent :: __construct($query, $moduleName, 'bk');
|
||||
|
|
@ -89,7 +91,11 @@ class ApiQueryBlocks extends ApiQueryBase {
|
|||
if(isset($params['ids']))
|
||||
$this->addWhere(array('ipb_id' => $params['ids']));
|
||||
if(isset($params['users']))
|
||||
$this->addWhere(array('ipb_address' => $params['users']));
|
||||
{
|
||||
foreach((array)$params['users'] as $u)
|
||||
$this->prepareUsername($u);
|
||||
$this->addWhere(array('ipb_address' => $this->usernames));
|
||||
}
|
||||
if(!$wgUser->isAllowed('suppress'))
|
||||
$this->addWhere(array('ipb_deleted' => 0));
|
||||
|
||||
|
|
@ -152,6 +158,21 @@ class ApiQueryBlocks extends ApiQueryBase {
|
|||
$result->setIndexedTagName($data, 'block');
|
||||
$result->addValue('query', $this->getModuleName(), $data);
|
||||
}
|
||||
|
||||
protected function prepareUsername($user) {
|
||||
if( $user ) {
|
||||
$name = User::isIP( $user )
|
||||
? $user
|
||||
: User::getCanonicalName( $user, 'valid' );
|
||||
if( $name === false ) {
|
||||
$this->dieUsage( "User name {$user} is not valid", 'param_user' );
|
||||
} else {
|
||||
$this->usernames[] = $name;
|
||||
}
|
||||
} else {
|
||||
$this->dieUsage( 'User parameter may not be empty', 'param_user' );
|
||||
}
|
||||
}
|
||||
|
||||
protected function convertHexIP($ip)
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in a new issue