API: Avoid duplicate logs to api-feature-usage
[lhc/web/wiklou.git] / includes / Title.php
index 849707e..0b74a17 100644 (file)
@@ -2620,8 +2620,9 @@ class Title implements LinkTarget, IDBAccessObject {
                $useReplica = ( $rigor !== 'secure' );
                $block = $user->getBlock( $useReplica );
 
-               // The block may explicitly allow an action (like "read" or "upload").
-               if ( $block && $block->prevents( $action ) === false ) {
+               // If the user does not have a block, or the block they do have explicitly
+               // allows the action (like "read" or "upload").
+               if ( !$block || $block->appliesToRight( $action ) === false ) {
                        return $errors;
                }
 
@@ -2650,9 +2651,7 @@ class Title implements LinkTarget, IDBAccessObject {
                if ( !$actionObj || $actionObj->requiresUnblock() ) {
                        if ( $user->isBlockedFrom( $this, $useReplica ) ) {
                                // @todo FIXME: Pass the relevant context into this function.
-                               $errors[] = $block
-                                       ? $block->getPermissionsError( RequestContext::getMain() )
-                                       : [ 'actionblockedtext' ];
+                               $errors[] = $block->getPermissionsError( RequestContext::getMain() );
                        }
                }
 
@@ -3338,7 +3337,7 @@ class Title implements LinkTarget, IDBAccessObject {
                                $dbr = wfGetDB( DB_MASTER );
                                $rows = $loadRestrictionsFromDb( $dbr );
                        } else {
-                               $cache = ObjectCache::getMainWANInstance();
+                               $cache = MediaWikiServices::getInstance()->getMainWANObjectCache();
                                $rows = $cache->getWithSetCallback(
                                        // Page protections always leave a new null revision
                                        $cache->makeKey( 'page-restrictions', $id, $this->getLatestRevID() ),
@@ -3984,28 +3983,6 @@ class Title implements LinkTarget, IDBAccessObject {
                return $errors ?: true;
        }
 
-       /**
-        * Check if the requested move target is a valid file move target
-        * @todo move this to MovePage
-        * @param Title $nt Target title
-        * @return array List of errors
-        */
-       protected function validateFileMoveOperation( $nt ) {
-               global $wgUser;
-
-               $errors = [];
-
-               $destFile = wfLocalFile( $nt );
-               $destFile->load( File::READ_LATEST );
-               if ( !$wgUser->isAllowed( 'reupload-shared' )
-                       && !$destFile->exists() && wfFindFile( $nt )
-               ) {
-                       $errors[] = [ 'file-exists-sharedrepo' ];
-               }
-
-               return $errors;
-       }
-
        /**
         * Move a title to a new location
         *