Inject PermissionManager in SpecialReplaceText

Change-Id: Ifdacf22494297698c263c9236d7807eee49b674a
This commit is contained in:
Fomafix 2023-10-18 20:29:09 +00:00
parent f3087681b5
commit 74c973a2a9
2 changed files with 9 additions and 3 deletions

View file

@ -31,6 +31,7 @@
"LinkRenderer", "LinkRenderer",
"MovePageFactory", "MovePageFactory",
"NamespaceInfo", "NamespaceInfo",
"PermissionManager",
"ReadOnlyMode", "ReadOnlyMode",
"SearchEngineConfig", "SearchEngineConfig",
"SlotRoleStore", "SlotRoleStore",

View file

@ -25,8 +25,8 @@ use Language;
use MediaWiki\HookContainer\HookContainer; use MediaWiki\HookContainer\HookContainer;
use MediaWiki\Html\Html; use MediaWiki\Html\Html;
use MediaWiki\Linker\LinkRenderer; use MediaWiki\Linker\LinkRenderer;
use MediaWiki\MediaWikiServices;
use MediaWiki\Page\MovePageFactory; use MediaWiki\Page\MovePageFactory;
use MediaWiki\Permissions\PermissionManager;
use MediaWiki\Revision\SlotRecord; use MediaWiki\Revision\SlotRecord;
use MediaWiki\SpecialPage\SpecialPage; use MediaWiki\SpecialPage\SpecialPage;
use MediaWiki\Storage\NameTableStore; use MediaWiki\Storage\NameTableStore;
@ -71,6 +71,9 @@ class SpecialReplaceText extends SpecialPage {
/** @var NamespaceInfo */ /** @var NamespaceInfo */
private $namespaceInfo; private $namespaceInfo;
/** @var PermissionManager */
private $permissionManager;
/** @var ReadOnlyMode */ /** @var ReadOnlyMode */
private $readOnlyMode; private $readOnlyMode;
@ -93,6 +96,7 @@ class SpecialReplaceText extends SpecialPage {
* @param LinkRenderer $linkRenderer * @param LinkRenderer $linkRenderer
* @param MovePageFactory $movePageFactory * @param MovePageFactory $movePageFactory
* @param NamespaceInfo $namespaceInfo * @param NamespaceInfo $namespaceInfo
* @param PermissionManager $permissionManager
* @param ReadOnlyMode $readOnlyMode * @param ReadOnlyMode $readOnlyMode
* @param SearchEngineConfig $searchEngineConfig * @param SearchEngineConfig $searchEngineConfig
* @param NameTableStore $slotRoleStore * @param NameTableStore $slotRoleStore
@ -106,6 +110,7 @@ class SpecialReplaceText extends SpecialPage {
LinkRenderer $linkRenderer, LinkRenderer $linkRenderer,
MovePageFactory $movePageFactory, MovePageFactory $movePageFactory,
NamespaceInfo $namespaceInfo, NamespaceInfo $namespaceInfo,
PermissionManager $permissionManager,
ReadOnlyMode $readOnlyMode, ReadOnlyMode $readOnlyMode,
SearchEngineConfig $searchEngineConfig, SearchEngineConfig $searchEngineConfig,
NameTableStore $slotRoleStore, NameTableStore $slotRoleStore,
@ -119,6 +124,7 @@ class SpecialReplaceText extends SpecialPage {
$this->linkRenderer = $linkRenderer; $this->linkRenderer = $linkRenderer;
$this->movePageFactory = $movePageFactory; $this->movePageFactory = $movePageFactory;
$this->namespaceInfo = $namespaceInfo; $this->namespaceInfo = $namespaceInfo;
$this->permissionManager = $permissionManager;
$this->readOnlyMode = $readOnlyMode; $this->readOnlyMode = $readOnlyMode;
$this->searchEngineConfig = $searchEngineConfig; $this->searchEngineConfig = $searchEngineConfig;
$this->slotRoleStore = $slotRoleStore; $this->slotRoleStore = $slotRoleStore;
@ -673,8 +679,7 @@ class SpecialReplaceText extends SpecialPage {
// If the user is a bot, don't even show the "Mark changes as bot edits" checkbox - // If the user is a bot, don't even show the "Mark changes as bot edits" checkbox -
// presumably a bot user should never be allowed to make non-bot edits. // presumably a bot user should never be allowed to make non-bot edits.
$permissionManager = MediaWikiServices::getInstance()->getPermissionManager(); if ( !$this->permissionManager->userHasRight( $this->getReplaceTextUser(), 'bot' ) ) {
if ( !$permissionManager->userHasRight( $this->getReplaceTextUser(), 'bot' ) ) {
$out->addHTML( $out->addHTML(
'<br />' . '<br />' .
Xml::checkLabel( Xml::checkLabel(