mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-30 17:14:42 +00:00
Replace deprecated PermissionManager::getPermissionErrors() and friends
Change-Id: Ic217af5f9766ae2d7850597a4aec1a890d58766f
This commit is contained in:
parent
459a6e2605
commit
326b4a2804
|
@ -31,6 +31,7 @@ use MediaWiki\Logger\LoggerFactory;
|
||||||
use MediaWiki\MediaWikiServices;
|
use MediaWiki\MediaWikiServices;
|
||||||
use MediaWiki\Page\PageReference;
|
use MediaWiki\Page\PageReference;
|
||||||
use MediaWiki\Page\WikiPageFactory;
|
use MediaWiki\Page\WikiPageFactory;
|
||||||
|
use MediaWiki\Permissions\PermissionManager;
|
||||||
use MediaWiki\Request\DerivativeRequest;
|
use MediaWiki\Request\DerivativeRequest;
|
||||||
use MediaWiki\Revision\RevisionLookup;
|
use MediaWiki\Revision\RevisionLookup;
|
||||||
use MediaWiki\SpecialPage\SpecialPageFactory;
|
use MediaWiki\SpecialPage\SpecialPageFactory;
|
||||||
|
@ -322,14 +323,14 @@ class ApiVisualEditor extends ApiBase {
|
||||||
$builder = new TextboxBuilder();
|
$builder = new TextboxBuilder();
|
||||||
$protectedClasses = $builder->getTextboxProtectionCSSClasses( $title );
|
$protectedClasses = $builder->getTextboxProtectionCSSClasses( $title );
|
||||||
|
|
||||||
// Simplified EditPage::getEditPermissionErrors()
|
// Simplified EditPage::getEditPermissionStatus()
|
||||||
// TODO: Use API
|
// TODO: Use API
|
||||||
// action=query&prop=info&intestactions=edit&intestactionsdetail=full&errorformat=html&errorsuselocal=1
|
// action=query&prop=info&intestactions=edit&intestactionsdetail=full&errorformat=html&errorsuselocal=1
|
||||||
$permErrors = $permissionManager->getPermissionErrors(
|
$status = $permissionManager->getPermissionStatus(
|
||||||
'edit', $this->getUserForPermissions(), $title, 'full' );
|
'edit', $this->getUserForPermissions(), $title, PermissionManager::RIGOR_FULL );
|
||||||
if ( $permErrors ) {
|
if ( !$status->isGood() ) {
|
||||||
// Show generic permission errors, including page protection, user blocks, etc.
|
// Show generic permission errors, including page protection, user blocks, etc.
|
||||||
$notice = $this->getOutput()->formatPermissionsErrorMessage( $permErrors, 'edit' );
|
$notice = $this->getOutput()->formatPermissionStatus( $status, 'edit' );
|
||||||
// That method returns wikitext (eww), hack to get it parsed:
|
// That method returns wikitext (eww), hack to get it parsed:
|
||||||
$notice = ( new RawMessage( '$1', [ $notice ] ) )->page( $title )->parseAsBlock();
|
$notice = ( new RawMessage( '$1', [ $notice ] ) )->page( $title )->parseAsBlock();
|
||||||
// Invent a message key 'permissions-error' to store in $notices
|
// Invent a message key 'permissions-error' to store in $notices
|
||||||
|
@ -358,14 +359,14 @@ class ApiVisualEditor extends ApiBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Will be false e.g. if user is blocked or page is protected
|
// Will be false e.g. if user is blocked or page is protected
|
||||||
$canEdit = !$permErrors;
|
$canEdit = $status->isGood();
|
||||||
|
|
||||||
$blockinfo = null;
|
$blockinfo = null;
|
||||||
// Blocked user notice
|
// Blocked user notice
|
||||||
if ( $permissionManager->isBlockedFrom( $user, $title, true ) ) {
|
if ( $permissionManager->isBlockedFrom( $user, $title, true ) ) {
|
||||||
$block = $user->getBlock();
|
$block = $user->getBlock();
|
||||||
if ( $block ) {
|
if ( $block ) {
|
||||||
// Already added to $notices via #getPermissionErrors above.
|
// Already added to $notices via #getPermissionStatus above.
|
||||||
// Add block info for MobileFrontend:
|
// Add block info for MobileFrontend:
|
||||||
$blockinfo = $this->getBlockDetails( $block );
|
$blockinfo = $this->getBlockDetails( $block );
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue