24 use Psr\Log\LoggerAwareInterface;
25 use Psr\Log\LoggerInterface;
26 use Psr\Log\NullLogger;
58 $this->resourceloader = $rl;
59 $this->logger =
$logger ?:
new NullLogger();
64 $this->wanCache = MediaWikiServices::getInstance()->getMainWANObjectCache();
85 return $blobs[$module->
getName()];
103 $cache->makeGlobalKey( __CLASS__ )
106 foreach (
$modules as $name => $module ) {
108 $cacheKeys[$name] = $cacheKey;
110 $checkKeys[$cacheKey][] =
$cache->makeKey( __CLASS__, $name );
113 $result =
$cache->getMulti( array_values( $cacheKeys ), $curTTLs, $checkKeys );
116 foreach (
$modules as $name => $module ) {
117 $key = $cacheKeys[$name];
118 if ( !isset( $result[$key] ) || $curTTLs[$key] ===
null || $curTTLs[$key] < 0 ) {
122 $blobs[$name] = $result[$key];
135 $messages = array_values( array_unique( $module->
getMessages() ) );
137 return $this->wanCache->makeKey( __CLASS__, $module->
getName(),
$lang,
138 md5( json_encode( $messages ) )
154 $cache::TTL_WEEK + mt_rand( 0, $cache::TTL_DAY ),
168 foreach ( $moduleNames as $moduleName ) {
170 $this->wanCache->touchCheckKey( $this->wanCache->makeKey( __CLASS__, $moduleName ) );
196 $cache->touchCheckKey(
$cache->makeGlobalKey( __CLASS__ ), $cache::HOLDOFF_TTL_NONE );
215 if ( !$message->exists() ) {
216 $this->logger->warning(
'Failed to find {messageKey} ({lang})', [
217 'messageKey' => $key,
222 $value = $message->plain();
238 if ( $value !==
null ) {
239 $messages[$key] = $value;
245 if ( $json ===
false ) {
246 $this->logger->warning(
'Failed to encode message blob for {module} ({lang})', [
247 'module' => $module->
getName(),