+ if ( $time !== false ) {
+ $img = $this->newFile( $title, $time );
+ if ( $img && $img->exists() ) {
+ if ( !$img->isDeleted(File::DELETED_FILE) ) {
+ return $img;
+ } else if ( !empty( $options['private'] ) && $img->userCan(File::DELETED_FILE) ) {
+ return $img;
+ }
+ }
+ }
+
+ # Now try redirects
+ if ( !empty( $options['ignoreRedirect'] ) ) {
+ return false;
+ }
+ $redir = $this->checkRedirect( $title );
+ if( $redir && $redir->getNamespace() == NS_FILE) {
+ $img = $this->newFile( $redir );
+ if( !$img ) {
+ return false;
+ }
+ if( $img->exists() ) {
+ $img->redirectedFrom( $title->getDBkey() );
+ return $img;
+ }
+ }
+ return false;
+ }
+
+ /*
+ * Find many files at once.
+ * @param array $items, an array of titles, or an array of findFile() options with
+ * the "title" option giving the title. Example:
+ *
+ * $findItem = array( 'title' => $title, 'private' => true );
+ * $findBatch = array( $findItem );
+ * $repo->findFiles( $findBatch );
+ */
+ function findFiles( $items ) {
+ $result = array();
+ foreach ( $items as $index => $item ) {
+ if ( is_array( $item ) ) {
+ $title = $item['title'];
+ $options = $item;
+ unset( $options['title'] );
+ } else {
+ $title = $item;
+ $options = array();
+ }
+ $file = $this->findFile( $title, $options );
+ if ( $file )
+ $result[$file->getTitle()->getDBkey()] = $file;
+ }
+ return $result;
+ }
+
+ /**
+ * Create a new File object from the local repository
+ * @param mixed $sha1 SHA-1 key
+ * @param mixed $time Time at which the image was uploaded.
+ * If this is specified, the returned object will be an
+ * instance of the repository's old file class instead of
+ * a current file. Repositories not supporting version
+ * control should return false if this parameter is set.
+ */
+ function newFileFromKey( $sha1, $time = false ) {
+ if ( $time ) {
+ if ( $this->oldFileFactoryKey ) {
+ return call_user_func( $this->oldFileFactoryKey, $sha1, $this, $time );
+ } else {
+ return false;
+ }
+ } else {
+ return call_user_func( $this->fileFactoryKey, $sha1, $this );
+ }
+ }
+
+ /**
+ * Find an instance of the file with this key, created at the specified time
+ * Returns false if the file does not exist. Repositories not supporting
+ * version control should return false if the time is specified.
+ *
+ * @param string $sha1 string
+ * @param array $options Option array, same as findFile().
+ */
+ function findFileFromKey( $sha1, $options = array() ) {
+ if ( !is_array( $options ) ) {
+ # MW 1.15 compat
+ $time = $options;
+ } else {
+ $time = isset( $options['time'] ) ? $options['time'] : false;
+ }
+
+ # First try the current version of the file to see if it precedes the timestamp
+ $img = $this->newFileFromKey( $sha1 );
+ if ( !$img ) {
+ return false;
+ }
+ if ( $img->exists() && ( !$time || $img->getTimestamp() == $time ) ) {