X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=blobdiff_plain;f=thumb.php;h=c699bb19ab1cc87bed4e3a95a05f76b86401a1c5;hp=bd14e417a6f9a16ad8a8b3cd8c1e1bb10e10fda1;hb=731654cf413621e47802c3d6e7737b1f9e6db6dd;hpb=88081365b3604e51922151bb2de3185f6f8b5896 diff --git a/thumb.php b/thumb.php index bd14e417a6..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, 3600 + 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, 3600 + mt_rand( 0, 300 ) ); + $cache->incrWithInit( $key, $cache::TTL_HOUR + mt_rand( 0, 300 ) ); } return array( $thumb, $errorHtml );