X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=blobdiff_plain;f=includes%2Fcache%2FMessageBlobStore.php;h=90ad24192db35075c39624e0d6375c167634afab;hp=a2e46d30d44fbad199278ac42b29deddf22b73a5;hb=ce079cf6ad79ca8d3360817f809b219d166f9153;hpb=7b0d1e1590f87871cb25441e4d20b7c5ae80813e diff --git a/includes/cache/MessageBlobStore.php b/includes/cache/MessageBlobStore.php index a2e46d30d4..90ad24192d 100644 --- a/includes/cache/MessageBlobStore.php +++ b/includes/cache/MessageBlobStore.php @@ -75,7 +75,7 @@ class MessageBlobStore implements LoggerAwareInterface { * @return string JSON */ public function getBlob( ResourceLoaderModule $module, $lang ) { - $blobs = $this->getBlobs( array( $module->getName() => $module ), $lang ); + $blobs = $this->getBlobs( [ $module->getName() => $module ], $lang ); return $blobs[$module->getName()]; } @@ -92,26 +92,26 @@ class MessageBlobStore implements LoggerAwareInterface { // check key without language code. This is used to invalidate any and all language subkeys // that exist for a module from the updateMessage() method. $cache = $this->wanCache; - $checkKeys = array( + $checkKeys = [ // Global check key, see clear() $cache->makeKey( __CLASS__ ) - ); - $cacheKeys = array(); + ]; + $cacheKeys = []; foreach ( $modules as $name => $module ) { $cacheKey = $this->makeCacheKey( $module, $lang ); $cacheKeys[$name] = $cacheKey; // Per-module check key, see updateMessage() $checkKeys[$cacheKey][] = $cache->makeKey( __CLASS__, $name ); } - $curTTLs = array(); + $curTTLs = []; $result = $cache->getMulti( array_values( $cacheKeys ), $curTTLs, $checkKeys ); - $blobs = array(); + $blobs = []; foreach ( $modules as $name => $module ) { $key = $cacheKeys[$name]; if ( !isset( $result[$key] ) || $curTTLs[$key] === null || $curTTLs[$key] < 0 ) { $this->logger->info( 'Message blob cache-miss for {module}', - array( 'module' => $name, 'cacheKey' => $key ) + [ 'module' => $name, 'cacheKey' => $key ] ); $blobs[$name] = $this->recacheMessageBlob( $key, $module, $lang ); } else { @@ -165,7 +165,7 @@ class MessageBlobStore implements LoggerAwareInterface { $cache->set( $cacheKey, $blob, // Add part of a day to TTL to avoid all modules expiring at once $cache::TTL_WEEK + mt_rand( 0, $cache::TTL_DAY ), - Database::getCacheSetOptions( wfGetDB( DB_SLAVE ) ) + Database::getCacheSetOptions( wfGetDB( DB_REPLICA ) ) ); return $blob; } @@ -179,7 +179,7 @@ class MessageBlobStore implements LoggerAwareInterface { public function updateMessage( $key ) { $moduleNames = $this->getResourceLoader()->getModulesByMessage( $key ); foreach ( $moduleNames as $moduleName ) { - // Uses a holdoff to account for database slave lag (for MessageCache) + // Uses a holdoff to account for database replica DB lag (for MessageCache) $this->wanCache->touchCheckKey( $this->wanCache->makeKey( __CLASS__, $moduleName ) ); } } @@ -219,10 +219,10 @@ class MessageBlobStore implements LoggerAwareInterface { $message = wfMessage( $key )->inLanguage( $lang ); $value = $message->plain(); if ( !$message->exists() ) { - $this->logger->warning( 'Failed to find {messageKey} ({lang})', array( + $this->logger->warning( 'Failed to find {messageKey} ({lang})', [ 'messageKey' => $key, 'lang' => $lang, - ) ); + ] ); } return $value; } @@ -235,17 +235,17 @@ class MessageBlobStore implements LoggerAwareInterface { * @return string JSON blob */ private function generateMessageBlob( ResourceLoaderModule $module, $lang ) { - $messages = array(); + $messages = []; foreach ( $module->getMessages() as $key ) { $messages[$key] = $this->fetchMessage( $key, $lang ); } $json = FormatJson::encode( (object)$messages ); if ( $json === false ) { - $this->logger->warning( 'Failed to encode message blob for {module} ({lang})', array( + $this->logger->warning( 'Failed to encode message blob for {module} ({lang})', [ 'module' => $module->getName(), 'lang' => $lang, - ) ); + ] ); $json = '{}'; } return $json;