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