From d099d3e3cda436774841d60c193b4eff03b37ef0 Mon Sep 17 00:00:00 2001 From: Patrick Westerhoff Date: Sat, 25 Oct 2014 03:51:28 +0200 Subject: [PATCH] API: Make `usernames` a local variable Instead of having a single-purpose instance variable, keep the array local. This also allows reusing `prepareUsername` for other parameters. Change-Id: Iea7c3c1f24a371a665ebdbeeb3e827262246f1b3 --- includes/api/ApiQueryBlocks.php | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/includes/api/ApiQueryBlocks.php b/includes/api/ApiQueryBlocks.php index 5c44173c04..b7779a7317 100644 --- a/includes/api/ApiQueryBlocks.php +++ b/includes/api/ApiQueryBlocks.php @@ -31,11 +31,6 @@ */ class ApiQueryBlocks extends ApiQueryBase { - /** - * @var array - */ - protected $usernames; - public function __construct( ApiQuery $query, $moduleName ) { parent::__construct( $query, $moduleName, 'bk' ); } @@ -102,10 +97,11 @@ class ApiQueryBlocks extends ApiQueryBase { $this->addWhereFld( 'ipb_id', $params['ids'] ); } if ( isset( $params['users'] ) ) { + $usernames = array(); foreach ( (array)$params['users'] as $u ) { - $this->prepareUsername( $u ); + $usernames[] = $this->prepareUsername( $u ); } - $this->addWhereFld( 'ipb_address', $this->usernames ); + $this->addWhereFld( 'ipb_address', $usernames ); $this->addWhereFld( 'ipb_auto', 0 ); } if ( isset( $params['ip'] ) ) { @@ -264,7 +260,7 @@ class ApiQueryBlocks extends ApiQueryBase { if ( $name === false ) { $this->dieUsage( "User name {$user} is not valid", 'param_user' ); } - $this->usernames[] = $name; + return $name; } public function getAllowedParams() { -- 2.20.1