Merge "Remove unused WikiPage::getLastNAuthors() method"
[lhc/web/wiklou.git] / includes / filerepo / FileRepo.php
index 25e46d8..647dbec 100644 (file)
@@ -52,6 +52,9 @@ class FileRepo {
        /** @var bool */
        protected $hasSha1Storage = false;
 
+       /** @var bool */
+       protected $supportsSha1URLs = false;
+
        /** @var FileBackend */
        protected $backend;
 
@@ -76,7 +79,7 @@ class FileRepo {
        protected $scriptDirUrl;
 
        /** @var string Script extension of the MediaWiki installation, equivalent
-        *    to $wgScriptExtension, e.g. .php5 defaults to .php */
+        *    to the old $wgScriptExtension, e.g. .php5 defaults to .php */
        protected $scriptExtension;
 
        /** @var string Equivalent to $wgArticlePath, e.g. https://en.wikipedia.org/wiki/$1 */
@@ -200,6 +203,8 @@ class FileRepo {
                                $this->zones[$zone]['urlsByExt'] = array();
                        }
                }
+
+               $this->supportsSha1URLs = !empty( $info['supportsSha1URLs'] );
        }
 
        /**
@@ -1590,13 +1595,26 @@ class FileRepo {
         *
         * @param string $virtualUrl
         * @param array $headers Additional HTTP headers to send on success
-        * @return bool Success
+        * @return Status
+        * @since 1.27
         */
-       public function streamFile( $virtualUrl, $headers = array() ) {
+       public function streamFileWithStatus( $virtualUrl, $headers = array() ) {
                $path = $this->resolveToStoragePath( $virtualUrl );
                $params = array( 'src' => $path, 'headers' => $headers );
 
-               return $this->backend->streamFile( $params )->isOK();
+               return $this->backend->streamFile( $params );
+       }
+
+       /**
+        * Attempt to stream a file with the given virtual URL/storage path
+        *
+        * @deprecated since 1.26, use streamFileWithStatus
+        * @param string $virtualUrl
+        * @param array $headers Additional HTTP headers to send on success
+        * @return bool Success
+        */
+       public function streamFile( $virtualUrl, $headers = array() ) {
+               return $this->streamFileWithStatus( $virtualUrl, $headers )->isOK();
        }
 
        /**
@@ -1894,6 +1912,14 @@ class FileRepo {
        public function hasSha1Storage() {
                return $this->hasSha1Storage;
        }
+
+       /**
+        * Returns whether or not repo supports having originals SHA-1s in the thumb URLs
+        * @return boolean
+        */
+       public function supportsSha1URLs() {
+               return $this->supportsSha1URLs;
+       }
 }
 
 /**