r112683 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r112682‎ | r112683 | r112684 >
Date:13:28, 29 February 2012
Author:nikerabbit
Status:ok
Tags:
Comment:
Don't rely on wgMemc being a real cache
Modified paths:
  • /trunk/extensions/Translate/tag/TranslatablePage.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Translate/tag/TranslatablePage.php
@@ -617,15 +617,15 @@
618618 }
619619
620620 public function getTranslationPercentages( $force = false ) {
621 - // Check the memory cache, as this is very slow to calculate
622 - global $wgMemc, $wgRequest;
 621+ global $wgRequest;
623622
 623+ // Check the cache, as this is relatively slow to calculate
624624 $memcKey = wfMemcKey( 'pt', 'status', $this->getTitle()->getPrefixedText() );
625 - $cache = $wgMemc->get( $memcKey );
 625+ $cached = wfGetCache( CACHE_ANYTHING )->get( $memcKey );
626626
627627 $force = $force || $wgRequest->getText( 'action' ) === 'purge';
628 - if ( !$force && is_array( $cache ) ) {
629 - return $cache;
 628+ if ( !$force && is_array( $cached ) ) {
 629+ return $cached;
630630 }
631631
632632 $titles = $this->getTranslationPages();
@@ -653,7 +653,7 @@
654654
655655 $temp[$wgContLang->getCode()] = 1.00;
656656
657 - $wgMemc->set( $memcKey, $temp, 60 * 60 * 12 );
 657+ wfGetCache( CACHE_ANYTHING )->set( $memcKey, $temp, 60 * 60 * 12 );
658658
659659 return $temp;
660660 }

Status & tagging log