X-Git-Url: https://git.cyclocoop.org/?a=blobdiff_plain;f=thumb.php;h=03a3f354e66bd2f245403b20bab1a2a03022e3f0;hb=8406759dd4131575920db0c3e16844f20801138c;hp=40f375480e0d2600af4f44350a55da347a91adcf;hpb=a77c09c03baf8ee1dd7527db4c20c5be2cd2c298;p=lhc%2Fweb%2Fwiklou.git diff --git a/thumb.php b/thumb.php index 40f375480e..03a3f354e6 100644 --- a/thumb.php +++ b/thumb.php @@ -89,7 +89,6 @@ function wfThumbHandle404() { function wfStreamThumb( array $params ) { global $wgVaryOnXFP; - $headers = array(); // HTTP headers to send $fileName = isset( $params['f'] ) ? $params['f'] : ''; @@ -214,6 +213,7 @@ function wfStreamThumb( array $params ) { if ( count( $varyHeader ) ) { $response->header( 'Vary: ' . implode( ', ', $varyHeader ) ); } + $response->header( 'Content-Length: 0' ); return; } @@ -235,7 +235,7 @@ function wfStreamThumb( array $params ) { $imsUnix = strtotime( $imsString ); MediaWiki\restoreWarnings(); if ( wfTimestamp( TS_UNIX, $img->getTimestamp() ) <= $imsUnix ) { - HttpStatus::header( 304 ); + HttpStatus::header( 304 ); return; } } @@ -302,9 +302,15 @@ function wfStreamThumb( array $params ) { // Stream the file if it exists already... $thumbPath = $img->getThumbPath( $thumbName ); if ( $img->getRepo()->fileExists( $thumbPath ) ) { + $starttime = microtime( true ); $success = $img->getRepo()->streamFile( $thumbPath, $headers ); + $streamtime = microtime( true ) - $starttime; + if ( !$success ) { wfThumbError( 500, 'Could not stream the file' ); + } else { + RequestContext::getMain()->getStats()->timing( 'media.thumbnail.stream', $streamtime ); + wfDebugLog( 'thumbnailaccess', time() . ' ' . $thumbPath . ' ' . ob_get_length() . ' Streamed ' ); } return; } @@ -318,8 +324,8 @@ function wfStreamThumb( array $params ) { return; } - // Actually generate a new thumbnail list( $thumb, $errorMsg ) = wfGenerateThumbnail( $img, $params, $thumbName, $thumbPath ); + /** @var MediaTransformOutput|bool $thumb */ // Check for thumbnail generation errors... @@ -571,7 +577,7 @@ function wfThumbError( $status, $msg ) { } else { $debug = ''; } - echo << @@ -587,4 +593,6 @@ $debug EOT; + header( 'Content-Length: ' . strlen( $content ) ); + echo $content; }