Merge "cleanupTitles: Don't add 'Broken/' prefix if the title is valid without it"
[lhc/web/wiklou.git] / includes / filerepo / FileRepo.php
index f89d96b..b4df68a 100644 (file)
@@ -124,7 +124,7 @@ class FileRepo {
        protected $isPrivate;
 
        /** @var array callable Override these in the base class */
-       protected $fileFactory = [ 'UnregisteredLocalFile', 'newFromTitle' ];
+       protected $fileFactory = [ UnregisteredLocalFile::class, 'newFromTitle' ];
        /** @var array callable|bool Override these in the base class */
        protected $oldFileFactory = false;
        /** @var array callable|bool Override these in the base class */
@@ -1543,7 +1543,7 @@ class FileRepo {
         */
        public function getFileProps( $virtualUrl ) {
                $fsFile = $this->getLocalReference( $virtualUrl );
-               $mwProps = new MWFileProps( MimeMagic::singleton() );
+               $mwProps = new MWFileProps( MediaWiki\MediaWikiServices::getInstance()->getMimeAnalyzer() );
                if ( $fsFile ) {
                        $props = $mwProps->getPropsFromPath( $fsFile->getPath(), true );
                } else {
@@ -1602,9 +1602,15 @@ class FileRepo {
                $path = $this->resolveToStoragePath( $virtualUrl );
                $params = [ 'src' => $path, 'headers' => $headers, 'options' => $optHeaders ];
 
+               // T172851: HHVM does not flush the output properly, causing OOM
+               ob_start( null, 1048576 );
+               ob_implicit_flush( true );
+
                $status = $this->newGood();
                $status->merge( $this->backend->streamFile( $params ) );
 
+               ob_end_flush();
+
                return $status;
        }
 
@@ -1716,7 +1722,7 @@ class FileRepo {
         * @return Status
         */
        public function newFatal( $message /*, parameters...*/ ) {
-               $status = call_user_func_array( [ 'Status', 'newFatal' ], func_get_args() );
+               $status = call_user_func_array( [ Status::class, 'newFatal' ], func_get_args() );
                $status->cleanCallback = $this->getErrorCleanupFunction();
 
                return $status;