Merge "registration: Add --config-prefix to convertExtensionToRegistration.php"
[lhc/web/wiklou.git] / includes / filerepo / FileBackendDBRepoWrapper.php
index 0401d0c..aec337e 100644 (file)
@@ -46,7 +46,7 @@ class FileBackendDBRepoWrapper extends FileBackend {
        protected $dbHandleFunc;
        /** @var ProcessCacheLRU */
        protected $resolvedPathCache;
-       /** @var Array Map of (index => DBConnRef) */
+       /** @var DBConnRef[] */
        protected $dbs;
 
        public function __construct( array $config ) {
@@ -79,7 +79,7 @@ class FileBackendDBRepoWrapper extends FileBackend {
         * @return string
         */
        public function getBackendPath( $path, $latest = true ) {
-               $paths = $this->getBackendPaths( array( $path ), $latest );
+               $paths = $this->getBackendPaths( [ $path ], $latest );
                return current( $paths );
        }
 
@@ -95,28 +95,27 @@ class FileBackendDBRepoWrapper extends FileBackend {
         */
        public function getBackendPaths( array $paths, $latest = true ) {
                $db = $this->getDB( $latest ? DB_MASTER : DB_SLAVE );
-               $origBasePath = $this->backend->getContainerStoragePath( "{$this->repoName}-original" );
 
                // @TODO: batching
-               $resolved = array();
+               $resolved = [];
                foreach ( $paths as $i => $path ) {
                        if ( !$latest && $this->resolvedPathCache->has( $path, 'target', 10 ) ) {
                                $resolved[$i] = $this->resolvedPathCache->get( $path, 'target' );
                                continue;
                        }
 
-                       list( , $container, $rel ) = FileBackend::splitStoragePath( $path );
+                       list( , $container ) = FileBackend::splitStoragePath( $path );
 
                        if ( $container === "{$this->repoName}-public" ) {
                                $name = basename( $path );
                                if ( strpos( $path, '!' ) !== false ) {
                                        $sha1 = $db->selectField( 'oldimage', 'oi_sha1',
-                                               array( 'oi_archive_name' => $name ),
+                                               [ 'oi_archive_name' => $name ],
                                                __METHOD__
                                        );
                                } else {
                                        $sha1 = $db->selectField( 'image', 'img_sha1',
-                                               array( 'img_name' => $name ),
+                                               [ 'img_name' => $name ],
                                                __METHOD__
                                        );
                                }
@@ -136,7 +135,7 @@ class FileBackendDBRepoWrapper extends FileBackend {
                        }
                }
 
-               $res = array();
+               $res = [];
                foreach ( $paths as $i => $path ) {
                        $res[$i] = $resolved[$i];
                }
@@ -258,7 +257,7 @@ class FileBackendDBRepoWrapper extends FileBackend {
        }
 
        public function getScopedLocksForOps( array $ops, Status $status ) {
-               return $this->backend->getScopedFileLocks( $ops, $status );
+               return $this->backend->getScopedLocksForOps( $ops, $status );
        }
 
        /**
@@ -271,7 +270,7 @@ class FileBackendDBRepoWrapper extends FileBackend {
         */
        public function getPathForSHA1( $sha1 ) {
                if ( strlen( $sha1 ) < 3 ) {
-                       throw new MWException( "Invalid file SHA-1." );
+                       throw new InvalidArgumentException( "Invalid file SHA-1." );
                }
                return $this->backend->getContainerStoragePath( "{$this->repoName}-original" ) .
                        "/{$sha1[0]}/{$sha1[1]}/{$sha1[2]}/{$sha1}";
@@ -284,11 +283,11 @@ class FileBackendDBRepoWrapper extends FileBackend {
         * @return DBConnRef
         */
        protected function getDB( $index ) {
-               if ( !isset( $this->db[$index] ) ) {
+               if ( !isset( $this->dbs[$index] ) ) {
                        $func = $this->dbHandleFunc;
-                       $this->db[$index] = $func( $index );
+                       $this->dbs[$index] = $func( $index );
                }
-               return $this->db[$index];
+               return $this->dbs[$index];
        }
 
        /**
@@ -325,7 +324,7 @@ class FileBackendDBRepoWrapper extends FileBackend {
 
                $results = $this->backend->$function( $params );
 
-               $contents = array();
+               $contents = [];
                foreach ( $results as $path => $result ) {
                        $contents[$pathMap[$path]] = $result;
                }
@@ -343,7 +342,7 @@ class FileBackendDBRepoWrapper extends FileBackend {
         */
        protected function mungeOpPaths( array $ops ) {
                // Ops that use 'src' and do not mutate core file data there
-               static $srcRefOps = array( 'store', 'copy', 'describe' );
+               static $srcRefOps = [ 'store', 'copy', 'describe' ];
                foreach ( $ops as &$op ) {
                        if ( isset( $op['src'] ) && in_array( $op['op'], $srcRefOps ) ) {
                                $op['src'] = $this->getBackendPath( $op['src'], true );