r84918 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r84917‎ | r84918 | r84919 >
Date:19:57, 28 March 2011
Author:nelson
Status:reverted (Comments)
Tags:
Comment:
findFileFromKey, newFileFromKey, $fileFactoryKey, and $oldFileFactoryKey weren't used by anything in .../extensions nor .../phase3
Modified paths:
  • /trunk/phase3/includes/filerepo/FileRepo.php (modified) (history)
  • /trunk/phase3/includes/filerepo/RepoGroup.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/filerepo/FileRepo.php
@@ -30,7 +30,6 @@
3131 * Override these in the base class
3232 */
3333 var $fileFactory = false, $oldFileFactory = false;
34 - var $fileFactoryKey = false, $oldFileFactoryKey = false;
3534
3635 function __construct( $info ) {
3736 // Required settings
@@ -179,63 +178,6 @@
180179 }
181180
182181 /**
183 - * Create a new File object from the local repository
184 - * @param $sha1 Mixed: base 36 SHA-1 hash
185 - * @param $time Mixed: time at which the image was uploaded.
186 - * If this is specified, the returned object will be an
187 - * of the repository's old file class instead of a current
188 - * file. Repositories not supporting version control should
189 - * return false if this parameter is set.
190 - *
191 - * @return File
192 - */
193 - function newFileFromKey( $sha1, $time = false ) {
194 - if ( $time ) {
195 - if ( $this->oldFileFactoryKey ) {
196 - return call_user_func( $this->oldFileFactoryKey, $sha1, $this, $time );
197 - }
198 - } else {
199 - if ( $this->fileFactoryKey ) {
200 - return call_user_func( $this->fileFactoryKey, $sha1, $this );
201 - }
202 - }
203 - return false;
204 - }
205 -
206 - /**
207 - * Find an instance of the file with this key, created at the specified time
208 - * Returns false if the file does not exist. Repositories not supporting
209 - * version control should return false if the time is specified.
210 - *
211 - * @param $sha1 String base 36 SHA-1 hash
212 - * @param $options Option array, same as findFile().
213 - */
214 - function findFileFromKey( $sha1, $options = array() ) {
215 - $time = isset( $options['time'] ) ? $options['time'] : false;
216 -
217 - # First try the current version of the file to see if it precedes the timestamp
218 - $img = $this->newFileFromKey( $sha1 );
219 - if ( !$img ) {
220 - return false;
221 - }
222 - if ( $img->exists() && ( !$time || $img->getTimestamp() == $time ) ) {
223 - return $img;
224 - }
225 - # Now try an old version of the file
226 - if ( $time !== false ) {
227 - $img = $this->newFileFromKey( $sha1, $time );
228 - if ( $img && $img->exists() ) {
229 - if ( !$img->isDeleted(File::DELETED_FILE) ) {
230 - return $img;
231 - } else if ( !empty( $options['private'] ) && $img->userCan(File::DELETED_FILE) ) {
232 - return $img;
233 - }
234 - }
235 - }
236 - return false;
237 - }
238 -
239 - /**
240182 * Get the URL of thumb.php
241183 */
242184 function getThumbScriptUrl() {
Index: trunk/phase3/includes/filerepo/RepoGroup.php
@@ -212,29 +212,6 @@
213213 }
214214
215215 /**
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 base 36 SHA-1 hash
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 - /**
239216 * Find all instances of files with this key
240217 *
241218 * @param $hash String base 36 SHA-1 hash

Follow-up revisions

RevisionCommit summaryAuthorDate
r84924Reverted r84918 per CRaaron21:40, 28 March 2011

Comments

#Comment by Reedy (talk | contribs)   21:28, 28 March 2011

Line 3431 of Parser.php

			$file = RepoGroup::singleton()->findFileFromKey( $sha1, array( 'time' => $time ) );

Status & tagging log