+ } );
+
+ $thumb = false;
+ $errorHtml = false;
+
+ // Thumbnail isn't already there, so create the new thumbnail...
+ try {
+ $work = new PoolCounterWorkViaCallback( 'FileRender', sha1( $file->getName() ),
+ array(
+ 'doWork' => function() use ( $file, $params ) {
+ return $file->transform( $params, File::RENDER_NOW );
+ },
+ 'getCachedWork' => function() use ( $file, $params ) {
+ return $file->transform( $params );
+ },
+ 'fallback' => function() {
+ return wfMessage( 'generic-pool-error' )->parse();
+ },
+ 'error' => function ( $status ) {
+ return $status->getHTML();
+ }
+ )
+ );
+ $result = $work->execute();
+ if ( $result instanceof MediaTransformOutput ) {
+ $thumb = $result;
+ } elseif ( is_string( $result ) ) { // error
+ $errorHtml = $result;
+ }
+ } catch ( Exception $e ) {
+ // Tried to select a page on a non-paged file?
+ }
+
+ $done = true; // no PHP fatal occured
+
+ if ( !$thumb || $thumb->isError() ) {
+ $wgMemc->incrWithInit( $key, 3600 );