From: Gergő Tisza Date: Fri, 27 Jun 2014 19:39:47 +0000 (+0000) Subject: Use separate PoolCounter config for expensive thumbnails X-Git-Tag: 1.31.0-rc.0~15195^2 X-Git-Url: http://git.cyclocoop.org/%24image?a=commitdiff_plain;h=3ee07d8bb4cad2eb265c140f92dd7169e601b2a1;p=lhc%2Fweb%2Fwiklou.git Use separate PoolCounter config for expensive thumbnails Depends on Ic62984e0f4a761642b2bdd1bfa362301ed94c284 and If40e223c328ddd15310d13f2a49000bf6e08200e Bug: 65691 Change-Id: Ic737673b5a31974d866b9bf5afa4b4036baa03bb --- diff --git a/thumb.php b/thumb.php index d7bf453382..c611dc3ca7 100644 --- a/thumb.php +++ b/thumb.php @@ -387,9 +387,17 @@ function wfGenerateThumbnail( File $file, array $params, $thumbName, $thumbPath $thumb = false; $errorHtml = false; + // guard thumbnail rendering with PoolCounter to avoid stampedes + // expensive files use a separate PoolCounter config so it is possible to set up a global limit on them + if ( $file->isExpensiveToThumbnail() ) { + $poolCounterType = 'FileRenderExpensive'; + } else { + $poolCounterType = 'FileRender'; + } + // Thumbnail isn't already there, so create the new thumbnail... try { - $work = new PoolCounterWorkViaCallback( 'FileRender', sha1( $file->getName() ), + $work = new PoolCounterWorkViaCallback( $poolCounterType, sha1( $file->getName() ), array( 'doWork' => function() use ( $file, $params ) { return $file->transform( $params, File::RENDER_NOW );