From: Aaron Schulz Date: Wed, 28 Oct 2015 04:40:01 +0000 (-0700) Subject: Convert wfGenerateThumbnail() away from $wgMemc X-Git-Tag: 1.31.0-rc.0~9199 X-Git-Url: http://git.cyclocoop.org/%24image?a=commitdiff_plain;h=d101295ac603c482a7bc032143d5cd59cfff1eb2;p=lhc%2Fweb%2Fwiklou.git Convert wfGenerateThumbnail() away from $wgMemc Change-Id: I06c2d90cb3e75142f781afa80f917d4155513a22 --- diff --git a/thumb.php b/thumb.php index 8daf301eed..c699bb19ab 100644 --- a/thumb.php +++ b/thumb.php @@ -376,23 +376,28 @@ function wfStreamThumb( array $params ) { * @return array (MediaTransformOutput|bool, string|bool error message HTML) */ function wfGenerateThumbnail( File $file, array $params, $thumbName, $thumbPath ) { - global $wgMemc, $wgAttemptFailureEpoch; + global $wgAttemptFailureEpoch; - $key = wfMemcKey( 'attempt-failures', $wgAttemptFailureEpoch, - $file->getRepo()->getName(), $file->getSha1(), md5( $thumbName ) ); + $cache = ObjectCache::getLocalClusterInstance(); + $key = $cache->makeKey( + 'attempt-failures', + $wgAttemptFailureEpoch, + $file->getRepo()->getName(), + $file->getSha1(), + md5( $thumbName ) + ); // Check if this file keeps failing to render - if ( $wgMemc->get( $key ) >= 4 ) { + if ( $cache->get( $key ) >= 4 ) { return array( false, wfMessage( 'thumbnail_image-failure-limit', 4 ) ); } $done = false; // Record failures on PHP fatals in addition to caching exceptions - register_shutdown_function( function () use ( &$done, $key ) { + register_shutdown_function( function () use ( $cache, &$done, $key ) { if ( !$done ) { // transform() gave a fatal - global $wgMemc; // Randomize TTL to reduce stampedes - $wgMemc->incrWithInit( $key, $wgMemc::TTL_HOUR + mt_rand( 0, 300 ) ); + $cache->incrWithInit( $key, $cache::TTL_HOUR + mt_rand( 0, 300 ) ); } } ); @@ -445,7 +450,7 @@ function wfGenerateThumbnail( File $file, array $params, $thumbName, $thumbPath if ( !$thumb || $thumb->isError() ) { // Randomize TTL to reduce stampedes - $wgMemc->incrWithInit( $key, $wgMemc::TTL_HOUR + mt_rand( 0, 300 ) ); + $cache->incrWithInit( $key, $cache::TTL_HOUR + mt_rand( 0, 300 ) ); } return array( $thumb, $errorHtml );