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 = $wanObjectCache ?: MediaWikiServices::getInstance()
65 ->getMainWANObjectCache();
86 return $blobs[$module->
getName()];
104 $cache->makeGlobalKey( __CLASS__ )
107 foreach (
$modules as $name => $module ) {
109 $cacheKeys[$name] = $cacheKey;
111 $checkKeys[$cacheKey][] =
$cache->makeKey( __CLASS__, $name );
114 $result =
$cache->getMulti( array_values( $cacheKeys ), $curTTLs, $checkKeys );
117 foreach (
$modules as $name => $module ) {
118 $key = $cacheKeys[$name];
119 if ( !isset( $result[$key] ) || $curTTLs[$key] ===
null || $curTTLs[$key] < 0 ) {
123 $blobs[$name] = $result[$key];
136 $messages = array_values( array_unique( $module->
getMessages() ) );
138 return $this->wanCache->makeKey( __CLASS__, $module->
getName(),
$lang,
139 md5( json_encode( $messages ) )
155 $cache::TTL_WEEK + mt_rand( 0, $cache::TTL_DAY ),
168 $moduleNames = $this->resourceloader->getModulesByMessage( $key );
169 foreach ( $moduleNames as $moduleName ) {
171 $this->wanCache->touchCheckKey( $this->wanCache->makeKey( __CLASS__, $moduleName ) );
197 $cache->touchCheckKey(
$cache->makeGlobalKey( __CLASS__ ), $cache::HOLDOFF_TTL_NONE );
208 if ( !$message->exists() ) {
209 $this->logger->warning(
'Failed to find {messageKey} ({lang})', [
210 'messageKey' => $key,
215 $value = $message->plain();
233 if ( $value !==
null ) {
234 $messages[$key] = $value;
240 if ( $json ===
false ) {
241 $this->logger->warning(
'Failed to encode message blob for {module} ({lang})', [
242 'module' => $module->
getName(),