X-Git-Url: http://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fmedia%2FDjVu.php;h=9add138da027d0bb214df06a00fafa29671b1a05;hb=010410265a5505b44a273bb119d8fac7f1fa7739;hp=d4ef8a875ebb5ca4cf29f4f03970e504bfbdef9d;hpb=a7047b3b6bb0d8396a50cb626ea7fa5aab4bc4d8;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/media/DjVu.php b/includes/media/DjVu.php index d4ef8a875e..9add138da0 100644 --- a/includes/media/DjVu.php +++ b/includes/media/DjVu.php @@ -393,25 +393,24 @@ class DjVuHandler extends ImageHandler { } protected function getDimensionInfo( File $file ) { - $that = $this; - - return ObjectCache::getMainWANInstance()->getWithSetCallback( - wfMemcKey( 'file-djvu', 'dimensions', $file->getSha1() ), - WANObjectCache::TTL_INDEFINITE, - function () use ( $that, $file ) { - $tree = $that->getMetaTree( $file ); + $cache = ObjectCache::getMainWANInstance(); + return $cache->getWithSetCallback( + $cache->makeKey( 'file-djvu', 'dimensions', $file->getSha1() ), + $cache::TTL_INDEFINITE, + function () use ( $file ) { + $tree = $this->getMetaTree( $file ); if ( !$tree ) { return false; } $dimsByPage = []; $count = count( $tree->xpath( '//OBJECT' ) ); - for ( $i = 0; $i < $count; ++$i ) { + for ( $i = 0; $i < $count; $i++ ) { $o = $tree->BODY[0]->OBJECT[$i]; if ( $o ) { $dimsByPage[$i] = [ 'width' => (int)$o['width'], - 'height' => (int)$o['height'] + 'height' => (int)$o['height'], ]; } else { $dimsByPage[$i] = false; @@ -419,7 +418,8 @@ class DjVuHandler extends ImageHandler { } return [ 'pageCount' => $count, 'dimensionsByPage' => $dimsByPage ]; - } + }, + [ 'pcTTL' => $cache::TTL_INDEFINITE ] ); }