Merge "Fix wrong return value in Preprocessor::getChildrenOfType"
[lhc/web/wiklou.git] / includes / filerepo / RepoGroup.php
index 0def2d8..f9e5759 100644 (file)
@@ -165,6 +165,10 @@ class RepoGroup {
                return $image;
        }
 
+       /**
+        * @param $inputItems array
+        * @return array
+        */
        function findFiles( $inputItems ) {
                if ( !$this->reposInitialised ) {
                        $this->initialiseRepos();
@@ -196,6 +200,7 @@ class RepoGroup {
 
        /**
         * Interface for FileRepo::checkRedirect()
+        * @param $title Title
         * @return bool
         */
        function checkRedirect( Title $title ) {
@@ -254,11 +259,35 @@ class RepoGroup {
                foreach ( $this->foreignRepos as $repo ) {
                        $result = array_merge( $result, $repo->findBySha1( $hash ) );
                }
+               usort( $result, 'File::compare' );
+               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
         * @return bool|LocalRepo
         */
        function getRepo( $index ) {
@@ -273,8 +302,10 @@ class RepoGroup {
                        return false;
                }
        }
+
        /**
         * Get the repo instance by its name
+        * @param $name string
         * @return bool
         */
        function getRepoByName( $name ) {
@@ -282,8 +313,9 @@ class RepoGroup {
                        $this->initialiseRepos();
                }
                foreach ( $this->foreignRepos as $repo ) {
-                       if ( $repo->name == $name)
+                       if ( $repo->name == $name ) {
                                return $repo;
+                       }
                }
                return false;
        }
@@ -351,6 +383,7 @@ class RepoGroup {
        /**
         * Split a virtual URL into repo, zone and rel parts
         * @param $url string
+        * @throws MWException
         * @return array containing repo, zone and rel
         */
        function splitVirtualUrl( $url ) {
@@ -365,6 +398,10 @@ class RepoGroup {
                return $bits;
        }
 
+       /**
+        * @param $fileName string
+        * @return array
+        */
        function getFileProps( $fileName ) {
                if ( FileRepo::isVirtualUrl( $fileName ) ) {
                        list( $repoName, /* $zone */, /* $rel */ ) = $this->splitVirtualUrl( $fileName );