Merge "Revert "Remove invalid language code "bh" (alias of "bho")""
[lhc/web/wiklou.git] / includes / filerepo / FileRepo.php
index d1a16b5..5b42c2c 100644 (file)
@@ -406,6 +406,7 @@ class FileRepo {
         *   private:        If true, return restricted (deleted) files if the current
         *                   user is allowed to view them. Otherwise, such files will not
         *                   be found. If a User object, use that user instead of the current.
+        *   latest:         If true, load from the latest available data into File objects
         * @return File|bool False on failure
         */
        public function findFile( $title, $options = array() ) {
@@ -413,18 +414,24 @@ class FileRepo {
                if ( !$title ) {
                        return false;
                }
+               if ( isset( $options['bypassCache'] ) ) {
+                       $options['latest'] = $options['bypassCache']; // b/c
+               }
                $time = isset( $options['time'] ) ? $options['time'] : false;
+               $flags = !empty( $options['latest'] ) ? File::READ_LATEST : 0;
                # First try the current version of the file to see if it precedes the timestamp
                $img = $this->newFile( $title );
                if ( !$img ) {
                        return false;
                }
+               $img->load( $flags );
                if ( $img->exists() && ( !$time || $img->getTimestamp() == $time ) ) {
                        return $img;
                }
                # Now try an old version of the file
                if ( $time !== false ) {
                        $img = $this->newFile( $title, $time );
+                       $img->load( $flags );
                        if ( $img && $img->exists() ) {
                                if ( !$img->isDeleted( File::DELETED_FILE ) ) {
                                        return $img; // always OK
@@ -445,6 +452,7 @@ class FileRepo {
                $redir = $this->checkRedirect( $title );
                if ( $redir && $title->getNamespace() == NS_FILE ) {
                        $img = $this->newFile( $redir );
+                       $img->load( $flags );
                        if ( !$img ) {
                                return false;
                        }