Merge "ApiVisualEditor: Return structured block info as well as formatted notice"

This commit is contained in:
jenkins-bot 2019-04-30 21:07:52 +00:00 committed by Gerrit Code Review
commit 78a0b4ea0f

View file

@ -487,27 +487,24 @@ class ApiVisualEditor extends ApiBase {
} }
} }
$block = null;
$blockinfo = null;
$permissionManager = MediaWikiServices::getInstance()->getPermissionManager();
// Blocked user notice // Blocked user notice
if ( $user->isBlockedFrom( $title, true ) || $user->isBlockedGlobally() ) { if ( $user->isBlockedGlobally() ) {
if ( $user->isBlockedFrom( $title, true ) ) { $block = $user->getGlobalBlock();
$notices[] = [ } elseif ( $permissionManager->isBlockedFrom( $user, $title, true ) ) {
'type' => 'block', $block = $user->getBlock();
'message' => call_user_func_array( }
[ $this, 'msg' ], if ( $block ) {
$user->getBlock()->getPermissionsError( $this->getContext() ) $notices[] = [
)->parseAsBlock(), 'type' => 'block',
]; 'message' => call_user_func_array(
} [ $this, 'msg' ],
$block->getPermissionsError( $this->getContext() )
if ( $user->isBlockedGlobally() ) { )->parseAsBlock(),
$notices[] = [ ];
'type' => 'block', $blockinfo = ApiQueryUserInfo::getBlockInfo( $block );
'message' => call_user_func_array(
[ $this, 'msg' ],
$user->getGlobalBlock()->getPermissionsError( $this->getContext() )
)->parseAsBlock(),
];
}
} }
// HACK: Build a fake EditPage so we can get checkboxes from it // HACK: Build a fake EditPage so we can get checkboxes from it
@ -566,7 +563,7 @@ class ApiVisualEditor extends ApiBase {
'basetimestamp' => $baseTimestamp, 'basetimestamp' => $baseTimestamp,
'starttimestamp' => wfTimestampNow(), 'starttimestamp' => wfTimestampNow(),
'oldid' => $oldid, 'oldid' => $oldid,
'blockinfo' => $blockinfo,
]; ];
if ( $params['paction'] === 'parse' || if ( $params['paction'] === 'parse' ||
$params['paction'] === 'wikitext' || $params['paction'] === 'wikitext' ||