X-Git-Url: https://git.cyclocoop.org/?a=blobdiff_plain;f=thumb.php;h=03a3f354e66bd2f245403b20bab1a2a03022e3f0;hb=8406759dd4131575920db0c3e16844f20801138c;hp=c77cddcd4ff73421758180fac258f7c99245e93d;hpb=3fec525cc4628bef4b936094d7d0e5bd8fc22e4e;p=lhc%2Fweb%2Fwiklou.git diff --git a/thumb.php b/thumb.php index c77cddcd4f..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; } @@ -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; }