X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=blobdiff_plain;f=includes%2Ffilerepo%2FFileRepo.php;h=0c37d78b2627ef76b1131da6324849ac4290d990;hp=50052807321ab2ddd4ca868527c5492cd7334afa;hb=30d72ec3d0914bb905d4114dee9256f02cbdcc7f;hpb=3df3b575c6617df64ec98533cc7141bd2314e274 diff --git a/includes/filerepo/FileRepo.php b/includes/filerepo/FileRepo.php index 5005280732..0c37d78b26 100644 --- a/includes/filerepo/FileRepo.php +++ b/includes/filerepo/FileRepo.php @@ -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 */ @@ -132,6 +132,13 @@ class FileRepo { /** @var array callable|bool Override these in the base class */ protected $oldFileFactoryKey = false; + /** @var string URL of where to proxy thumb.php requests to. + * Example: http://127.0.0.1:8888/wiki/dev/thumb/ + */ + protected $thumbProxyUrl; + /** @var string Secret key to pass as an X-Swift-Secret header to the proxied thumb service */ + protected $thumbProxySecret; + /** * @param array|null $info * @throws MWException @@ -159,7 +166,7 @@ class FileRepo { $optionalSettings = [ 'descBaseUrl', 'scriptDirUrl', 'articleUrl', 'fetchDescription', 'thumbScriptUrl', 'pathDisclosureProtection', 'descriptionCacheExpiry', - 'scriptExtension', 'favicon' + 'scriptExtension', 'favicon', 'thumbProxyUrl', 'thumbProxySecret' ]; foreach ( $optionalSettings as $var ) { if ( isset( $info[$var] ) ) { @@ -611,6 +618,24 @@ class FileRepo { return $this->thumbScriptUrl; } + /** + * Get the URL thumb.php requests are being proxied to + * + * @return string + */ + public function getThumbProxyUrl() { + return $this->thumbProxyUrl; + } + + /** + * Get the secret key for the proxied thumb service + * + * @return string + */ + public function getThumbProxySecret() { + return $this->thumbProxySecret; + } + /** * Returns true if the repository can transform files via a 404 handler * @@ -1293,9 +1318,9 @@ class FileRepo { } // Cleanup for disk source files... foreach ( $sourceFSFilesToDelete as $file ) { - MediaWiki\suppressWarnings(); + Wikimedia\suppressWarnings(); unlink( $file ); // FS cleanup - MediaWiki\restoreWarnings(); + Wikimedia\restoreWarnings(); } return $status; @@ -1543,7 +1568,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 { @@ -1609,7 +1634,11 @@ class FileRepo { $status = $this->newGood(); $status->merge( $this->backend->streamFile( $params ) ); - ob_end_flush(); + // T186565: Close the buffer, unless it has already been closed + // in HTTPFileStreamer::resetOutputBuffers(). + if ( ob_get_status() ) { + ob_end_flush(); + } return $status; } @@ -1722,7 +1751,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;