* Added findFileFromKey() function
authorAaron Schulz <aaron@users.mediawiki.org>
Sun, 20 Mar 2011 20:34:03 +0000 (20:34 +0000)
committerAaron Schulz <aaron@users.mediawiki.org>
Sun, 20 Mar 2011 20:34:03 +0000 (20:34 +0000)
* Added doc comments to findBySha1()

includes/filerepo/RepoGroup.php

index 4c712fd..80f94eb 100644 (file)
@@ -211,14 +211,44 @@ class RepoGroup {
                return false;
        }
 
+       /**
+        * Find an instance of the file with this key, created at the specified time
+        * Returns false if the file does not exist.
+        *
+        * @param $hash String SHA-1
+        * @param $options Option array, same as findFile()
+        * @return File object or false if it is not found
+        */
+       function findFileFromKey( $hash, $options = array() ) {
+               if ( !$this->reposInitialised ) {
+                       $this->initialiseRepos();
+               }
+
+               $file = $this->localRepo->findFileFromKey( $hash, $options );
+               if ( !$file ) {
+                       foreach ( $this->foreignRepos as $repo ) {
+                               $file = $repo->findFileFromKey( $hash, $options );
+                               if ( $file ) break;
+                       }
+               }
+               return $file;
+       }
+
+       /**
+        * Find all instances of files with this key
+        *
+        * @param $hash String SHA-1
+        * @return Array of File objects
+        */
        function findBySha1( $hash ) {
                if ( !$this->reposInitialised ) {
                        $this->initialiseRepos();
                }
 
                $result = $this->localRepo->findBySha1( $hash );
-               foreach ( $this->foreignRepos as $repo )
+               foreach ( $this->foreignRepos as $repo ) {
                        $result = array_merge( $result, $repo->findBySha1( $hash ) );
+               }
                return $result;
        }