From: Aaron Schulz Date: Mon, 26 Oct 2015 07:59:10 +0000 (-0700) Subject: Make DateFormatter::getInstance use APC X-Git-Tag: 1.31.0-rc.0~9238^2 X-Git-Url: https://git.cyclocoop.org/%7B%24admin_url%7Dcompta/operations/modifier.php?a=commitdiff_plain;h=d355471f1aecc0d475eef39d22b7946f52336b5d;p=lhc%2Fweb%2Fwiklou.git Make DateFormatter::getInstance use APC Change-Id: Idfff805903bffcdd6ff8f2a3c1331ca63476933e --- diff --git a/includes/parser/DateFormatter.php b/includes/parser/DateFormatter.php index ef295ab217..78f7775f76 100644 --- a/includes/parser/DateFormatter.php +++ b/includes/parser/DateFormatter.php @@ -124,18 +124,23 @@ class DateFormatter { * Defaults to the site content language * @return DateFormatter */ - public static function &getInstance( $lang = null ) { - global $wgMemc, $wgContLang; - static $dateFormatter = false; + public static function getInstance( $lang = null ) { + global $wgContLang, $wgMainCacheType; + $lang = $lang ? wfGetLangObj( $lang ) : $wgContLang; - $key = wfMemcKey( 'dateformatter', $lang->getCode() ); + $cache = ObjectCache::newAccelerator( $wgMainCacheType ); + + static $dateFormatter = false; if ( !$dateFormatter ) { - $dateFormatter = $wgMemc->get( $key ); - if ( !$dateFormatter ) { - $dateFormatter = new DateFormatter( $lang ); - $wgMemc->set( $key, $dateFormatter, 3600 ); - } + $dateFormatter = $cache->getWithSetCallback( + $cache->makeKey( 'dateformatter', $lang->getCode() ), + 3600, + function () use ( $lang ) { + return new DateFormatter( $lang ); + } + ); } + return $dateFormatter; }