public function getLocalRefPath() {
$this->assertRepoDefined();
if ( !isset( $this->fsFile ) ) {
+ $starttime = microtime( true );
$this->fsFile = $this->repo->getLocalReference( $this->getPath() );
+ RequestContext::getMain()->getStats()->timing( 'media.thumbnail.generate.fetchoriginal', microtime( true ) - $starttime );
+
if ( !$this->fsFile ) {
$this->fsFile = false; // null => false; cache negative hits
}
public function generateAndSaveThumb( $tmpFile, $transformParams, $flags ) {
global $wgUseSquid, $wgIgnoreImageErrors;
+ $stats = RequestContext::getMain()->getStats();
+
$handler = $this->getHandler();
$normalisedParams = $transformParams;
$this->generateBucketsIfNeeded( $normalisedParams, $flags );
}
+ $starttime = microtime( true );
+
// Actually render the thumbnail...
$thumb = $handler->doTransform( $this, $tmpThumbPath, $thumbUrl, $transformParams );
$tmpFile->bind( $thumb ); // keep alive with $thumb
+ $stats->timing( 'media.thumbnail.generate.transform', microtime( true ) - $starttime );
+
if ( !$thumb ) { // bad params?
$thumb = false;
} elseif ( $thumb->isError() ) { // transform error
}
} elseif ( $this->repo && $thumb->hasFile() && !$thumb->fileIsSource() ) {
// Copy the thumbnail from the file system into storage...
+
+ $starttime = microtime( true );
+
$disposition = $this->getThumbDisposition( $thumbName );
$status = $this->repo->quickImport( $tmpThumbPath, $thumbPath, $disposition );
if ( $status->isOK() ) {
} else {
$thumb = $this->transformErrorOutput( $thumbPath, $thumbUrl, $transformParams, $flags );
}
+
+ $stats->timing( 'media.thumbnail.generate.store', microtime( true ) - $starttime );
+
// Give extensions a chance to do something with this thumbnail...
Hooks::run( 'FileTransformed', array( $this, $thumb, $tmpThumbPath, $thumbPath ) );
}
// "thumbs" which have the main image URL though (bug 13776)
if ( $wgUseSquid ) {
if ( !$thumb || $thumb->isError() || $thumb->getUrl() != $this->getURL() ) {
+ $starttime = microtime( true );
+
SquidUpdate::purge( array( $thumbUrl ) );
+
+ $stats->timing( 'media.thumbnail.generate.purge', microtime( true ) - $starttime );
}
}
+
+
return $thumb;
}
return false;
}
+ $starttime = microtime( true );
+
$params['physicalWidth'] = $bucket;
$params['width'] = $bucket;
$thumb = $this->generateAndSaveThumb( $tmpFile, $params, $flags );
+ $buckettime = microtime( true ) - $starttime;
+
if ( !$thumb || $thumb->isError() ) {
return false;
}
// this object exists
$tmpFile->bind( $this );
+ RequestContext::getMain()->getStats()->timing( 'media.thumbnail.generate.bucket', $buckettime );
+
return true;
}
$headers[] = 'Vary: ' . implode( ', ', $varyHeader );
}
- $stats = RequestContext::getMain()->getStats();
-
// Stream the file if it exists already...
$thumbPath = $img->getThumbPath( $thumbName );
if ( $img->getRepo()->fileExists( $thumbPath ) ) {
if ( !$success ) {
wfThumbError( 500, 'Could not stream the file' );
} else {
- $stats->timing( 'media.thumbnail.stream', $streamtime );
+ RequestContext::getMain()->getStats()->timing( 'media.thumbnail.stream', $streamtime );
}
return;
}
return;
}
- // Actually generate a new thumbnail
- $starttime = microtime( true );
list( $thumb, $errorMsg ) = wfGenerateThumbnail( $img, $params, $thumbName, $thumbPath );
- $generatetime = microtime( true ) - $starttime;
+
/** @var MediaTransformOutput|bool $thumb */
// Check for thumbnail generation errors...
if ( $errorMsg !== false ) {
wfThumbError( $errorCode, $errorMsg );
} else {
- $stats->timing( 'media.thumbnail.generate', $generatetime );
-
// Stream the file if there were no errors
$success = $thumb->streamFile( $headers );
if ( !$success ) {