Merge "Track when block notices are returned on the api"

This commit is contained in:
jenkins-bot 2018-11-20 22:31:27 +00:00 committed by Gerrit Code Review
commit 44fcea9f65
2 changed files with 20 additions and 16 deletions

View file

@ -98,7 +98,8 @@
]
},
"VisualEditorEnableTocWidget": false,
"VisualEditorRebaserURL": false
"VisualEditorRebaserURL": false,
"VisualEditorTrackBlockNotices": false
},
"APIModules": {
"visualeditor": {

View file

@ -523,22 +523,25 @@ class ApiVisualEditor extends ApiBase {
}
// Blocked user notice
if (
$user->isBlockedFrom( $title, true ) &&
$user->getBlock()->prevents( 'edit' ) !== false
) {
$notices[] = call_user_func_array(
[ $this, 'msg' ],
$user->getBlock()->getPermissionsError( $this->getContext() )
)->parseAsBlock();
}
if ( $user->isBlockedFrom( $title, true ) || $user->isBlockedGlobally() ) {
if ( $user->isBlockedFrom( $title, true ) ) {
$notices[] = call_user_func_array(
[ $this, 'msg' ],
$user->getBlock()->getPermissionsError( $this->getContext() )
)->parseAsBlock();
}
// Blocked user notice for global blocks
if ( $user->isBlockedGlobally() ) {
$notices[] = call_user_func_array(
[ $this, 'msg' ],
$user->getGlobalBlock()->getPermissionsError( $this->getContext() )
)->parseAsBlock();
if ( $user->isBlockedGlobally() ) {
$notices[] = call_user_func_array(
[ $this, 'msg' ],
$user->getGlobalBlock()->getPermissionsError( $this->getContext() )
)->parseAsBlock();
}
if ( $this->veConfig->get( 'VisualEditorTrackBlockNotices' ) ) {
$statsd = MediaWikiServices::getInstance()->getStatsdDataFactory();
$statsd->increment( 'MediaWiki.BlockNotices.' . wfWikiID() . '.VisualEditor.returned' );
}
}
// HACK: Build a fake EditPage so we can get checkboxes from it