fix some spacing
[lhc/web/wiklou.git] / includes / filerepo / RepoGroup.php
index 6b31b7e..1f5ae91 100644 (file)
@@ -131,7 +131,7 @@ class RepoGroup {
                        $time = isset( $options['time'] ) ? $options['time'] : '';
                        $dbkey = $title->getDBkey();
                        if ( isset( $this->cache[$dbkey][$time] ) ) {
-                               wfDebug( __METHOD__.": got File:$dbkey from process cache\n" );
+                               wfDebug( __METHOD__ . ": got File:$dbkey from process cache\n" );
                                # Move it to the end of the list so that we can delete the LRU entry later
                                $this->pingCache( $dbkey );
                                # Return the entry
@@ -263,6 +263,28 @@ class RepoGroup {
                return $result;
        }
 
+       /**
+        * Find all instances of files with this keys
+        *
+        * @param $hashes Array base 36 SHA-1 hashes
+        * @return Array of array of File objects
+        */
+       function findBySha1s( array $hashes ) {
+               if ( !$this->reposInitialised ) {
+                       $this->initialiseRepos();
+               }
+
+               $result = $this->localRepo->findBySha1s( $hashes );
+               foreach ( $this->foreignRepos as $repo ) {
+                       $result = array_merge_recursive( $result, $repo->findBySha1s( $hashes ) );
+               }
+               //sort the merged (and presorted) sublist of each hash
+               foreach( $result as $hash => $files ) {
+                       usort( $result[$hash], 'File::compare' );
+               }
+               return $result;
+       }
+
        /**
         * Get the repo instance with a given key.
         * @param $index string|int
@@ -366,12 +388,12 @@ class RepoGroup {
         */
        function splitVirtualUrl( $url ) {
                if ( substr( $url, 0, 9 ) != 'mwrepo://' ) {
-                       throw new MWException( __METHOD__.': unknown protocol' );
+                       throw new MWException( __METHOD__ . ': unknown protocol' );
                }
 
                $bits = explode( '/', substr( $url, 9 ), 3 );
                if ( count( $bits ) != 3 ) {
-                       throw new MWException( __METHOD__.": invalid mwrepo URL: $url" );
+                       throw new MWException( __METHOD__ . ": invalid mwrepo URL: $url" );
                }
                return $bits;
        }
@@ -411,7 +433,7 @@ class RepoGroup {
                while ( count( $this->cache ) >= self::MAX_CACHE_SIZE ) {
                        reset( $this->cache );
                        $key = key( $this->cache );
-                       wfDebug( __METHOD__.": evicting $key\n" );
+                       wfDebug( __METHOD__ . ": evicting $key\n" );
                        unset( $this->cache[$key] );
                }
        }