Merge "WatchAction: Require POST for index.php action=watch"
[lhc/web/wiklou.git] / includes / filerepo / FileRepo.php
index e66fdaf..25e46d8 100644 (file)
@@ -49,6 +49,9 @@ class FileRepo {
        /** @var int */
        public $descriptionCacheExpiry;
 
+       /** @var bool */
+       protected $hasSha1Storage = false;
+
        /** @var FileBackend */
        protected $backend;
 
@@ -431,16 +434,18 @@ class FileRepo {
                # 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
-                               } elseif ( !empty( $options['private'] ) &&
-                                       $img->userCan( File::DELETED_FILE,
-                                               $options['private'] instanceof User ? $options['private'] : null
-                                       )
-                               ) {
-                                       return $img;
+                       if ( $img ) {
+                               $img->load( $flags );
+                               if ( $img->exists() ) {
+                                       if ( !$img->isDeleted( File::DELETED_FILE ) ) {
+                                               return $img; // always OK
+                                       } elseif ( !empty( $options['private'] ) &&
+                                               $img->userCan( File::DELETED_FILE,
+                                                       $options['private'] instanceof User ? $options['private'] : null
+                                               )
+                                       ) {
+                                               return $img;
+                                       }
                                }
                        }
                }
@@ -452,10 +457,10 @@ class FileRepo {
                $redir = $this->checkRedirect( $title );
                if ( $redir && $title->getNamespace() == NS_FILE ) {
                        $img = $this->newFile( $redir );
-                       $img->load( $flags );
                        if ( !$img ) {
                                return false;
                        }
+                       $img->load( $flags );
                        if ( $img->exists() ) {
                                $img->redirectedFrom( $title->getDBkey() );
 
@@ -748,7 +753,6 @@ class FileRepo {
                }
                if ( !is_null( $this->articleUrl ) ) {
                        # "http://example.com/wiki/$1"
-                       #
                        # We use "Image:" as the canonical namespace for
                        # compatibility across all MediaWiki versions.
                        return str_replace( '$1',
@@ -756,7 +760,6 @@ class FileRepo {
                }
                if ( !is_null( $this->scriptDirUrl ) ) {
                        # "http://example.com/w"
-                       #
                        # We use "Image:" as the canonical namespace for
                        # compatibility across all MediaWiki versions,
                        # and just sort of hope index.php is right. ;)
@@ -1883,6 +1886,14 @@ class FileRepo {
 
                return $ret;
        }
+
+       /**
+        * Returns whether or not storage is SHA-1 based
+        * @return boolean
+        */
+       public function hasSha1Storage() {
+               return $this->hasSha1Storage;
+       }
 }
 
 /**