X-Git-Url: https://git.cyclocoop.org/?a=blobdiff_plain;f=thumb.php;h=d53c10c93ea45ce1bad468b20130433667c0d13c;hb=6047d13f978f1bf0b9bb010239b0fb3c386b9c7c;hp=c0042c2c952cc06af717949906dd984b976d141e;hpb=9713929d364223efb2c23cfd3e6c481571e6a477;p=lhc%2Fweb%2Fwiklou.git diff --git a/thumb.php b/thumb.php index c0042c2c95..d53c10c93e 100644 --- a/thumb.php +++ b/thumb.php @@ -118,7 +118,7 @@ function wfStreamThumb( array $params ) { } if ( isset( $params['width'] ) && substr( $params['width'], -2 ) == 'px' ) { // strip the px (pixel) suffix, if found - $params['width'] = substr( $width, 0, strlen( $width ) - 2 ); + $params['width'] = substr( $params['width'], 0, -2 ); } if ( isset( $params['p'] ) ) { $params['page'] = $params['p']; @@ -376,7 +376,7 @@ function wfGenerateThumbnail( File $file, array $params, $thumbName, $thumbPath $done = false; // Record failures on PHP fatals in addition to caching exceptions - register_shutdown_function( function() use ( &$done, $key ) { + register_shutdown_function( function () use ( &$done, $key ) { if ( !$done ) { // transform() gave a fatal global $wgMemc; // Randomize TTL to reduce stampedes @@ -388,7 +388,8 @@ function wfGenerateThumbnail( File $file, array $params, $thumbName, $thumbPath $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 + // 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 { @@ -399,17 +400,17 @@ function wfGenerateThumbnail( File $file, array $params, $thumbName, $thumbPath try { $work = new PoolCounterWorkViaCallback( $poolCounterType, sha1( $file->getName() ), array( - 'doWork' => function() use ( $file, $params ) { + 'doWork' => function () use ( $file, $params ) { return $file->transform( $params, File::RENDER_NOW ); }, - 'getCachedWork' => function() use ( $file, $params, $thumbPath ) { + 'getCachedWork' => function () use ( $file, $params, $thumbPath ) { // If the worker that finished made this thumbnail then use it. // Otherwise, it probably made a different thumbnail for this file. return $file->getRepo()->fileExists( $thumbPath ) ? $file->transform( $params, File::RENDER_NOW ) : false; // retry once more in exclusive mode }, - 'fallback' => function() { + 'fallback' => function () { return wfMessage( 'generic-pool-error' )->parse(); }, 'error' => function ( $status ) { @@ -520,7 +521,8 @@ function wfExtractThumbRequestInfo( $thumbRel ) { $repo = RepoGroup::singleton()->getLocalRepo(); $hashDirReg = $subdirReg = ''; - for ( $i = 0; $i < $repo->getHashLevels(); $i++ ) { + $hashLevels = $repo->getHashLevels(); + for ( $i = 0; $i < $hashLevels; $i++ ) { $subdirReg .= '[0-9a-f]'; $hashDirReg .= "$subdirReg/"; }