Merge "Declare dynamic properties"
[lhc/web/wiklou.git] / includes / specials / SpecialMovepage.php
index 941d108..0767faf 100644 (file)
@@ -209,7 +209,9 @@ class MovePageForm extends UnlistedSpecialPage {
                }
 
                if ( count( $err ) == 1 && isset( $err[0][0] ) && $err[0][0] == 'file-exists-sharedrepo'
-                       && $user->isAllowed( 'reupload-shared' )
+                       && MediaWikiServices::getInstance()
+                                ->getPermissionManager()
+                                ->userHasRight( $user, 'reupload-shared' )
                ) {
                        $out->wrapWikiMsg(
                                "<div class='warningbox'>\n$1\n</div>\n",
@@ -305,8 +307,9 @@ class MovePageForm extends UnlistedSpecialPage {
                // mediawiki.special.movePage module
 
                $immovableNamespaces = [];
+               $namespaceInfo = MediaWikiServices::getInstance()->getNamespaceInfo();
                foreach ( array_keys( $this->getLanguage()->getNamespaces() ) as $nsId ) {
-                       if ( !MediaWikiServices::getInstance()->getNamespaceInfo()->isMovable( $nsId ) ) {
+                       if ( !$namespaceInfo->isMovable( $nsId ) ) {
                                $immovableNamespaces[] = $nsId;
                        }
                }
@@ -373,7 +376,10 @@ class MovePageForm extends UnlistedSpecialPage {
                        );
                }
 
-               if ( $user->isAllowed( 'suppressredirect' ) ) {
+               if ( MediaWikiServices::getInstance()
+                               ->getPermissionManager()
+                               ->userHasRight( $user, 'suppressredirect' )
+               ) {
                        if ( $handlerSupportsRedirects ) {
                                $isChecked = $this->leaveRedirect;
                                $isDisabled = false;
@@ -519,6 +525,7 @@ class MovePageForm extends UnlistedSpecialPage {
 
        function doSubmit() {
                $user = $this->getUser();
+               $permissionManager = MediaWikiServices::getInstance()->getPermissionManager();
 
                if ( $user->pingLimiter( 'move' ) ) {
                        throw new ThrottledError;
@@ -534,11 +541,14 @@ class MovePageForm extends UnlistedSpecialPage {
                        return;
                }
 
+               $services = MediaWikiServices::getInstance();
+
                # Show a warning if the target file exists on a shared repo
+               $repoGroup = $services->getRepoGroup();
                if ( $nt->getNamespace() == NS_FILE
-                       && !( $this->moveOverShared && $user->isAllowed( 'reupload-shared' ) )
-                       && !RepoGroup::singleton()->getLocalRepo()->findFile( $nt )
-                       && MediaWikiServices::getInstance()->getRepoGroup()->findFile( $nt )
+                       && !( $this->moveOverShared && $permissionManager->userHasRight( $user, 'reupload-shared' ) )
+                       && !$repoGroup->getLocalRepo()->findFile( $nt )
+                       && $repoGroup->findFile( $nt )
                ) {
                        $this->showForm( [ [ 'file-exists-sharedrepo' ] ] );
 
@@ -547,7 +557,7 @@ class MovePageForm extends UnlistedSpecialPage {
 
                # Delete to make way if requested
                if ( $this->deleteAndMove ) {
-                       $permErrors = $nt->getUserPermissionsErrors( 'delete', $user );
+                       $permErrors = $permissionManager->getPermissionErrors( 'delete', $user, $nt );
                        if ( count( $permErrors ) ) {
                                # Only show the first error
                                $this->showForm( $permErrors, true );
@@ -568,8 +578,7 @@ class MovePageForm extends UnlistedSpecialPage {
 
                        // Delete an associated image if there is
                        if ( $nt->getNamespace() == NS_FILE ) {
-                               $file = MediaWikiServices::getInstance()->getRepoGroup()->getLocalRepo()
-                                       ->newFile( $nt );
+                               $file = $repoGroup->getLocalRepo()->newFile( $nt );
                                $file->load( File::READ_LATEST );
                                if ( $file->exists() ) {
                                        $file->delete( $reason, false, $user );
@@ -589,7 +598,7 @@ class MovePageForm extends UnlistedSpecialPage {
 
                if ( !$handler->supportsRedirects() ) {
                        $createRedirect = false;
-               } elseif ( $user->isAllowed( 'suppressredirect' ) ) {
+               } elseif ( $permissionManager->userHasRight( $user, 'suppressredirect' ) ) {
                        $createRedirect = $this->leaveRedirect;
                } else {
                        $createRedirect = true;
@@ -604,7 +613,6 @@ class MovePageForm extends UnlistedSpecialPage {
                        $this->moveTalk = false;
                }
                if ( $this->moveSubpages ) {
-                       $permissionManager = MediaWikiServices::getInstance()->getPermissionManager();
                        $this->moveSubpages = $permissionManager->userCan( 'move-subpages', $user, $ot );
                }
 
@@ -670,7 +678,7 @@ class MovePageForm extends UnlistedSpecialPage {
                 */
 
                // @todo FIXME: Use Title::moveSubpages() here
-               $nsInfo = MediaWikiServices::getInstance()->getNamespaceInfo();
+               $nsInfo = $services->getNamespaceInfo();
                $dbr = wfGetDB( DB_MASTER );
                if ( $this->moveSubpages && (
                        $nsInfo->hasSubpages( $nt->getNamespace() ) || (