X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=blobdiff_plain;f=includes%2Fspecials%2FSpecialEditTags.php;h=0b4577eb98139fe4a8a4fec6beb6bf2da67f7839;hp=6ef6cb3f7d6971a20cfc867b778c36d950d13fb9;hb=9e8439e79d67788916d488f645108f79016d9aca;hpb=f79c9e6ca3c02090d6d56eaecb2ab90d4198b2b9 diff --git a/includes/specials/SpecialEditTags.php b/includes/specials/SpecialEditTags.php index 6ef6cb3f7d..0b4577eb98 100644 --- a/includes/specials/SpecialEditTags.php +++ b/includes/specials/SpecialEditTags.php @@ -19,6 +19,8 @@ * @ingroup SpecialPage */ +use MediaWiki\Permissions\PermissionManager; + /** * Special page for adding and removing change tags to individual revisions. * A lot of this is copied out of SpecialRevisiondelete. @@ -51,8 +53,18 @@ class SpecialEditTags extends UnlistedSpecialPage { /** @var string */ private $reason; - public function __construct() { + /** @var PermissionManager */ + private $permissionManager; + + /** + * @inheritDoc + * + * @param PermissionManager $permissionManager + */ + public function __construct( PermissionManager $permissionManager ) { parent::__construct( 'EditTags', 'changetags' ); + + $this->permissionManager = $permissionManager; } public function doesWrites() { @@ -67,13 +79,6 @@ class SpecialEditTags extends UnlistedSpecialPage { $user = $this->getUser(); $request = $this->getRequest(); - // Check blocks - // @TODO Use PermissionManager::isBlockedFrom() instead. - $block = $user->getBlock(); - if ( $block ) { - throw new UserBlockedError( $block ); - } - $this->setHeaders(); $this->outputHeader(); @@ -124,7 +129,7 @@ class SpecialEditTags extends UnlistedSpecialPage { $this->ids ); - $this->isAllowed = $user->isAllowed( 'changetags' ); + $this->isAllowed = $this->permissionManager->userHasRight( $user, 'changetags' ); $this->reason = $request->getVal( 'wpReason' ); // We need a target page! @@ -132,6 +137,12 @@ class SpecialEditTags extends UnlistedSpecialPage { $output->addWikiMsg( 'undelete-header' ); return; } + + // Check blocks + if ( $this->permissionManager->isBlockedFrom( $user, $this->targetObj ) ) { + throw new UserBlockedError( $user->getBlock() ); + } + // Give a link to the logs/hist for this page $this->showConvenienceLinks(); @@ -261,8 +272,7 @@ class SpecialEditTags extends UnlistedSpecialPage { // HTML maxlength uses "UTF-16 code units", which means that characters outside BMP // (e.g. emojis) count for two each. This limit is overridden in JS to instead count // Unicode codepoints. - // "- 155" is to leave room for the auto-generated part of the log entry. - 'maxlength' => CommentStore::COMMENT_CHARACTER_LIMIT - 155, + 'maxlength' => CommentStore::COMMENT_CHARACTER_LIMIT, ] ) . '' . "\n" . @@ -455,7 +465,7 @@ class SpecialEditTags extends UnlistedSpecialPage { protected function failure( $status ) { $this->getOutput()->setPageTitle( $this->msg( 'actionfailed' ) ); $this->getOutput()->wrapWikiTextAsInterface( - 'errorbox', $status->getWikiText( 'tags-edit-failure' ) + 'errorbox', $status->getWikiText( 'tags-edit-failure', false, $this->getLanguage() ) ); $this->showForm(); }