This is the logic to reproduce from thumb.php:
global $wgAttemptFailureEpoch; $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 ( $cache->get( $key ) >= 4 ) { return [ false, wfMessage( 'thumbnail_image-failure-limit', 4 ) ]; } $done = false; // Record failures on PHP fatals in addition to caching exceptions register_shutdown_function( function () use ( $cache, &$done, $key ) { if ( !$done ) { // transform() gave a fatal // Randomize TTL to reduce stampedes $cache->incrWithInit( $key, $cache::TTL_HOUR + mt_rand( 0, 300 ) ); } } );