X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=blobdiff_plain;f=includes%2Fspecials%2FSpecialUploadStash.php;h=c278babd64fd1040a452769a48c64036f7aa3439;hp=4d0c20c76a2296745b96900f0075f0690c07c55d;hb=9189db0c50cd4f755efc1d0ce061f6c04b236a40;hpb=f443cc5b9166a3eda5919a1d61d50663a721d591 diff --git a/includes/specials/SpecialUploadStash.php b/includes/specials/SpecialUploadStash.php index 4d0c20c76a..c278babd64 100644 --- a/includes/specials/SpecialUploadStash.php +++ b/includes/specials/SpecialUploadStash.php @@ -60,7 +60,7 @@ class SpecialUploadStash extends UnlistedSpecialPage { /** * Execute page -- can output a file directly or show a listing of them. * - * @param string $subPage Subpage, e.g. in + * @param string|null $subPage Subpage, e.g. in * https://example.com/wiki/Special:UploadStash/foo.jpg, the "foo.jpg" part * @return bool Success */ @@ -261,6 +261,15 @@ class SpecialUploadStash extends UnlistedSpecialPage { $scalerThumbUrl = $scalerBaseUrl . '/' . $file->getUrlRel() . '/' . rawurlencode( $scalerThumbName ); + // If a thumb proxy is set up for the repo, we favor that, as that will + // keep the request internal + $thumbProxyUrl = $file->getRepo()->getThumbProxyUrl(); + + if ( strlen( $thumbProxyUrl ) ) { + $scalerThumbUrl = $thumbProxyUrl . 'temp/' . $file->getUrlRel() . + '/' . rawurlencode( $scalerThumbName ); + } + // make an http request based on wgUploadStashScalerBaseUrl to lazy-create // a thumbnail $httpOptions = [ @@ -268,6 +277,14 @@ class SpecialUploadStash extends UnlistedSpecialPage { 'timeout' => 5 // T90599 attempt to time out cleanly ]; $req = MWHttpRequest::factory( $scalerThumbUrl, $httpOptions, __METHOD__ ); + + $secret = $file->getRepo()->getThumbProxySecret(); + + // Pass a secret key shared with the proxied service if any + if ( strlen( $secret ) ) { + $req->setHeader( 'X-Swift-Secret', $secret ); + } + $status = $req->execute(); if ( !$status->isOK() ) { $errors = $status->getErrorsArray(); @@ -305,10 +322,10 @@ class SpecialUploadStash extends UnlistedSpecialPage { ); } - return $file->getRepo()->streamFile( $file->getPath(), + return $file->getRepo()->streamFileWithStatus( $file->getPath(), [ 'Content-Transfer-Encoding: binary', 'Expires: Sun, 17-Jan-2038 19:14:07 GMT' ] - ); + )->isOK(); } /**