From 7ab2c2e2c3db05e4135d5cf2f117db13f837ff13 Mon Sep 17 00:00:00 2001 From: Brad Jorsch Date: Wed, 2 Sep 2015 09:14:20 -0400 Subject: [PATCH] ApiLogin: Don't try to add block info if there's no block Extensions such as CentralAuth can use various hooks to return USER_BLOCKED or CREATE_BLOCKED despite there being no local block. Bug: T111082 Change-Id: I3433a35547967852fc30bd56274392a186004a38 --- includes/api/ApiLogin.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/includes/api/ApiLogin.php b/includes/api/ApiLogin.php index 8c65310e6b..c66e215634 100644 --- a/includes/api/ApiLogin.php +++ b/includes/api/ApiLogin.php @@ -145,10 +145,10 @@ class ApiLogin extends ApiBase { case LoginForm::CREATE_BLOCKED: $result['result'] = 'CreateBlocked'; $result['details'] = 'Your IP address is blocked from account creation'; - $result = array_merge( - $result, - ApiQueryUserInfo::getBlockInfo( $context->getUser()->getBlock() ) - ); + $block = $context->getUser()->getBlock(); + if ( $block ) { + $result = array_merge( $result, ApiQueryUserInfo::getBlockInfo( $block ) ); + } break; case LoginForm::THROTTLED: @@ -159,10 +159,10 @@ class ApiLogin extends ApiBase { case LoginForm::USER_BLOCKED: $result['result'] = 'Blocked'; - $result = array_merge( - $result, - ApiQueryUserInfo::getBlockInfo( User::newFromName( $params['name'] )->getBlock() ) - ); + $block = User::newFromName( $params['name'] )->getBlock(); + if ( $block ) { + $result = array_merge( $result, ApiQueryUserInfo::getBlockInfo( $block ) ); + } break; case LoginForm::ABORTED: -- 2.20.1