function wfStreamThumb( array $params ) {
global $wgVaryOnXFP;
-
$headers = array(); // HTTP headers to send
$fileName = isset( $params['f'] ) ? $params['f'] : '';
$imsUnix = strtotime( $imsString );
MediaWiki\restoreWarnings();
if ( wfTimestamp( TS_UNIX, $img->getTimestamp() ) <= $imsUnix ) {
- HttpStatus::header( 304 );
+ HttpStatus::header( 304 );
return;
}
}
// 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 );
}
return;
}
return;
}
- // Actually generate a new thumbnail
list( $thumb, $errorMsg ) = wfGenerateThumbnail( $img, $params, $thumbName, $thumbPath );
+
/** @var MediaTransformOutput|bool $thumb */
// Check for thumbnail generation errors...
} else {
$debug = '';
}
- echo <<<EOT
+ $content = <<<EOT
<!DOCTYPE html>
<html><head>
<meta charset="UTF-8" />
</html>
EOT;
+ header( 'Content-Length: ' . strlen( $content ) );
+ echo $content;
}