- $key = wfMemcKey( 'file-djvu', 'dimensions', $image->getSha1() );
-
- $dimsByPage = $wgMemc->get( $key );
- if ( !is_array( $dimsByPage ) ) {
- $tree = $this->getMetaTree( $image );
- if ( !$tree ) {
- return false;
- }
-
- $dimsByPage = array();
- $count = count( $tree->xpath( '//OBJECT' ) );
- for ( $i = 0; $i < $count; ++$i ) {
- $o = $tree->BODY[0]->OBJECT[$i];
- if ( $o ) {
- $dimsByPage[$i] = array(
- 'width' => (int)$o['width'],
- 'height' => (int)$o['height']
- );
- } else {
- $dimsByPage[$i] = false;
+ return ObjectCache::getMainWANInstance()->getWithSetCallback(
+ wfMemcKey( 'file-djvu', 'dimensions', $file->getSha1() ),
+ WANObjectCache::TTL_INDEFINITE,
+ function () use ( $that, $file ) {
+ $tree = $that->getMetaTree( $file );
+ if ( !$tree ) {
+ return false;