X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=thumb.php;h=b59116eaed3881a68438e93489e65cdef551444d;hb=e25c45e2e3c8e6465fcd7edefd24156bd7b11a11;hp=c4b40dc76fa12888d2f9414a7a02b0e9b4265d12;hpb=a9f438227050c1fac6efe91fa8ff38947ae7c089;p=lhc%2Fweb%2Fwiklou.git diff --git a/thumb.php b/thumb.php index c4b40dc76f..cf9bd2cdfe 100644 --- a/thumb.php +++ b/thumb.php @@ -35,7 +35,7 @@ if ( defined( 'THUMB_HANDLER' ) ) { wfThumbHandle404(); } else { // Called directly, use $_GET params - wfStreamThumb( $_GET ); + wfStreamThumb( $wgRequest->getQueryValues() ); } $mediawiki = new MediaWiki(); @@ -94,7 +94,7 @@ function wfStreamThumb( array $params ) { $headers = []; // HTTP headers to send - $fileName = isset( $params['f'] ) ? $params['f'] : ''; + $fileName = $params['f'] ?? ''; // Backwards compatibility parameters if ( isset( $params['w'] ) ) { @@ -235,16 +235,16 @@ function wfStreamThumb( array $params ) { // Fix IE brokenness $imsString = preg_replace( '/;.*$/', '', $_SERVER["HTTP_IF_MODIFIED_SINCE"] ); // Calculate time - MediaWiki\suppressWarnings(); + Wikimedia\suppressWarnings(); $imsUnix = strtotime( $imsString ); - MediaWiki\restoreWarnings(); + Wikimedia\restoreWarnings(); if ( wfTimestamp( TS_UNIX, $img->getTimestamp() ) <= $imsUnix ) { HttpStatus::header( 304 ); return; } } - $rel404 = isset( $params['rel404'] ) ? $params['rel404'] : null; + $rel404 = $params['rel404'] ?? null; unset( $params['r'] ); // ignore 'r' because we unconditionally pass File::RENDER unset( $params['f'] ); // We're done with 'f' parameter. unset( $params['rel404'] ); // moved to $rel404 @@ -272,7 +272,7 @@ function wfStreamThumb( array $params ) { // For 404 handled thumbnails, we only use the base name of the URI // for the thumb params and the parent directory for the source file name. - // Check that the zone relative path matches up so squid caches won't pick + // Check that the zone relative path matches up so CDN caches won't pick // up thumbs that would not be purged on source file deletion (T36231). if ( $rel404 !== null ) { // thumbnail was handled via 404 if ( rawurldecode( $rel404 ) === $img->getThumbRel( $thumbName ) ) { @@ -409,6 +409,8 @@ function wfProxyThumbnailRequest( $img, $thumbName ) { // Send request to proxied service $status = $req->execute(); + MediaWiki\HeaderCallback::warnIfHeadersSent(); + // Simply serve the response from the proxied service as-is header( 'HTTP/1.1 ' . $req->getStatus() ); @@ -500,7 +502,7 @@ function wfGenerateThumbnail( File $file, array $params, $thumbName, $thumbPath } /** @noinspection PhpUnusedLocalVariableInspection */ - $done = true; // no PHP fatal occured + $done = true; // no PHP fatal occurred if ( !$thumb || $thumb->isError() ) { // Randomize TTL to reduce stampedes @@ -626,7 +628,7 @@ function wfThumbErrorText( $status, $msgText ) { * * @param int $status * @param string $msgHtml HTML - * @param string $msgText Short error description, for internal logging. Defaults to $msgHtml. + * @param string|null $msgText Short error description, for internal logging. Defaults to $msgHtml. * Only used for HTTP 500 errors. * @param array $context Error context, for internal logging. Only used for HTTP 500 errors. * @return void @@ -634,6 +636,8 @@ function wfThumbErrorText( $status, $msgText ) { function wfThumbError( $status, $msgHtml, $msgText = null, $context = [] ) { global $wgShowHostnames; + MediaWiki\HeaderCallback::warnIfHeadersSent(); + header( 'Cache-Control: no-cache' ); header( 'Content-Type: text/html; charset=utf-8' ); if ( $status == 400 || $status == 404 || $status == 429 ) { @@ -648,7 +652,7 @@ function wfThumbError( $status, $msgHtml, $msgText = null, $context = [] ) { if ( $wgShowHostnames ) { header( 'X-MW-Thumbnail-Renderer: ' . wfHostname() ); $url = htmlspecialchars( - isset( $_SERVER['REQUEST_URI'] ) ? $_SERVER['REQUEST_URI'] : '', + $_SERVER['REQUEST_URI'] ?? '', ENT_NOQUOTES ); $hostname = htmlspecialchars( wfHostname(), ENT_NOQUOTES );