diff options
author | Máté Szabó <mszabo@wikia-inc.com> | 2019-06-03 12:48:02 +0200 |
---|---|---|
committer | Máté Szabó <mszabo@wikia-inc.com> | 2019-06-03 13:03:46 +0200 |
commit | 6420c79320bc099cb4ff77232beabd72040146d0 (patch) | |
tree | 293d2b612286d9ce0ef1dcf0ccc7b731bef8c80a /includes/import | |
parent | 75cffa0b998b300b4d79ab3d1e7f61857d32b1aa (diff) | |
download | mediawikicore-6420c79320bc099cb4ff77232beabd72040146d0.tar.gz mediawikicore-6420c79320bc099cb4ff77232beabd72040146d0.zip |
Migrate remaining usages of Title::userCan() to PermissionManager
T208768 introduced the PermissionManager service that can now be used
for page specific permission checks. This change replaces remaining calls
to Title::userCan() with the new service in MediaWiki core.
Bug: T220191
Change-Id: Ie45e0cb6aa49a8c66147b470946161fc18160fc1
Diffstat (limited to 'includes/import')
-rw-r--r-- | includes/import/WikiImporter.php | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/includes/import/WikiImporter.php b/includes/import/WikiImporter.php index 8f583442ce6f..00bb61f7b284 100644 --- a/includes/import/WikiImporter.php +++ b/includes/import/WikiImporter.php @@ -1099,14 +1099,23 @@ class WikiImporter { } elseif ( !$title->canExist() ) { $this->notice( 'import-error-special', $title->getPrefixedText() ); return false; - } elseif ( !$title->userCan( 'edit' ) && !$commandLineMode ) { - # Do not import if the importing wiki user cannot edit this page - $this->notice( 'import-error-edit', $title->getPrefixedText() ); - return false; - } elseif ( !$title->exists() && !$title->userCan( 'create' ) && !$commandLineMode ) { - # Do not import if the importing wiki user cannot create this page - $this->notice( 'import-error-create', $title->getPrefixedText() ); - return false; + } elseif ( !$commandLineMode ) { + $permissionManager = MediaWikiServices::getInstance()->getPermissionManager(); + $user = RequestContext::getMain()->getUser(); + + if ( !$permissionManager->userCan( 'edit', $user, $title ) ) { + # Do not import if the importing wiki user cannot edit this page + $this->notice( 'import-error-edit', $title->getPrefixedText() ); + + return false; + } + + if ( !$title->exists() && !$permissionManager->userCan( 'create', $user, $title ) ) { + # Do not import if the importing wiki user cannot create this page + $this->notice( 'import-error-create', $title->getPrefixedText() ); + + return false; + } } return [ $title, $foreignTitle ]; |