Merge "mediawiki.util: Remove outdated comment from unit test"
[lhc/web/wiklou.git] / includes / jobqueue / JobQueueGroup.php
index a702d59..d6247cb 100644 (file)
@@ -381,23 +381,24 @@ class JobQueueGroup {
         * @return mixed
         */
        private function getCachedConfigVar( $name ) {
-               global $wgConf;
-
+               // @TODO: cleanup this whole method with a proper config system
                if ( $this->wiki === wfWikiID() ) {
                        return $GLOBALS[$name]; // common case
                } else {
-                       $cache = ObjectCache::getLocalClusterInstance();
-                       list( $db, $prefix ) = wfSplitWikiID( $this->wiki );
-                       $key = wfForeignMemcKey( $db, $prefix, 'configvalue', $name );
-                       $value = $cache->get( $key ); // ('v' => ...) or false
-                       if ( is_array( $value ) ) {
-                               return $value['v'];
-                       } else {
-                               $value = $wgConf->getConfig( $this->wiki, $name );
-                               $cache->set( $key, array( 'v' => $value ), 86400 + mt_rand( 0, 86400 ) );
-
-                               return $value;
-                       }
+                       $wiki = $this->wiki;
+                       $cache = ObjectCache::getMainWANInstance();
+                       $value = $cache->getWithSetCallback(
+                               $cache->makeGlobalKey( 'jobqueue', 'configvalue', $wiki, $name ),
+                               $cache::TTL_DAY + mt_rand( 0, $cache::TTL_DAY ),
+                               function () use ( $wiki, $name ) {
+                                       global $wgConf;
+
+                                       return array( 'v' => $wgConf->getConfig( $wiki, $name ) );
+                               },
+                               array( 'pcTTL' => 30 )
+                       );
+
+                       return $value['v'];
                }
        }