r84415 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r84414‎ | r84415 | r84416 >
Date:20:34, 20 March 2011
Author:aaron
Status:ok (Comments)
Tags:
Comment:
* Added findFileFromKey() function
* Added doc comments to findBySha1()
Modified paths:
  • /trunk/phase3/includes/filerepo/RepoGroup.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/filerepo/RepoGroup.php
@@ -211,14 +211,44 @@
212212 return false;
213213 }
214214
 215+ /**
 216+ * Find an instance of the file with this key, created at the specified time
 217+ * Returns false if the file does not exist.
 218+ *
 219+ * @param $hash String SHA-1
 220+ * @param $options Option array, same as findFile()
 221+ * @return File object or false if it is not found
 222+ */
 223+ function findFileFromKey( $hash, $options = array() ) {
 224+ if ( !$this->reposInitialised ) {
 225+ $this->initialiseRepos();
 226+ }
 227+
 228+ $file = $this->localRepo->findFileFromKey( $hash, $options );
 229+ if ( !$file ) {
 230+ foreach ( $this->foreignRepos as $repo ) {
 231+ $file = $repo->findFileFromKey( $hash, $options );
 232+ if ( $file ) break;
 233+ }
 234+ }
 235+ return $file;
 236+ }
 237+
 238+ /**
 239+ * Find all instances of files with this key
 240+ *
 241+ * @param $hash String SHA-1
 242+ * @return Array of File objects
 243+ */
215244 function findBySha1( $hash ) {
216245 if ( !$this->reposInitialised ) {
217246 $this->initialiseRepos();
218247 }
219248
220249 $result = $this->localRepo->findBySha1( $hash );
221 - foreach ( $this->foreignRepos as $repo )
 250+ foreach ( $this->foreignRepos as $repo ) {
222251 $result = array_merge( $result, $repo->findBySha1( $hash ) );
 252+ }
223253 return $result;
224254 }
225255

Sign-offs

UserFlagDate
Werdnainspected18:36, 15 July 2011
Tim Starlinginspected05:03, 2 September 2011

Comments

#Comment by Bryan (talk | contribs)   20:44, 20 March 2011

The comment needs to specify which base the hash needs to be in.

#Comment by Tim Starling (talk | contribs)   07:44, 1 September 2011

That was done in r84416.

Status & tagging log