From 0ad48b2ccc00daad847ebe8ee79002413048303c Mon Sep 17 00:00:00 2001 From: umherirrender Date: Fri, 22 Nov 2013 20:30:58 +0100 Subject: [PATCH] Always select ipb_deleted on list=[all]users When a user with the hideuser permission is using list=[all]users, a - Notice: Undefined property: stdClass::$ipb_deleted in \includes\api\ApiQueryUsers.php on line 172 - Notice: Undefined property: stdClass::$ipb_deleted in \includes\api\ApiQueryAllUsers.php on line 238 can be raised, because the join on the ipblocks table was not done for the user. Change-Id: I25ead34b7905e99c249cb05c9d4940195c8b6263 --- includes/api/ApiQueryBase.php | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/includes/api/ApiQueryBase.php b/includes/api/ApiQueryBase.php index cfc2244703..fcd318027d 100644 --- a/includes/api/ApiQueryBase.php +++ b/includes/api/ApiQueryBase.php @@ -547,24 +547,20 @@ abstract class ApiQueryBase extends ApiBase { * @return void */ public function showHiddenUsersAddBlockInfo( $showBlockInfo ) { - $userCanViewHiddenUsers = $this->getUser()->isAllowed( 'hideuser' ); - - if ( $showBlockInfo || !$userCanViewHiddenUsers ) { - $this->addTables( 'ipblocks' ); - $this->addJoinConds( array( - 'ipblocks' => array( 'LEFT JOIN', 'ipb_user=user_id' ), - ) ); + $this->addTables( 'ipblocks' ); + $this->addJoinConds( array( + 'ipblocks' => array( 'LEFT JOIN', 'ipb_user=user_id' ), + ) ); - $this->addFields( 'ipb_deleted' ); + $this->addFields( 'ipb_deleted' ); - if ( $showBlockInfo ) { - $this->addFields( array( 'ipb_id', 'ipb_by', 'ipb_by_text', 'ipb_reason', 'ipb_expiry' ) ); - } + if ( $showBlockInfo ) { + $this->addFields( array( 'ipb_id', 'ipb_by', 'ipb_by_text', 'ipb_reason', 'ipb_expiry' ) ); + } - // Don't show hidden names - if ( !$userCanViewHiddenUsers ) { - $this->addWhere( 'ipb_deleted = 0 OR ipb_deleted IS NULL' ); - } + // Don't show hidden names + if ( !$this->getUser()->isAllowed( 'hideuser' ) ) { + $this->addWhere( 'ipb_deleted = 0 OR ipb_deleted IS NULL' ); } } -- 2.20.1