MediaWiki REL1_37
MessageBlobStore Class Reference

This class generates message blobs for use by ResourceLoader. More...

Inheritance diagram for MessageBlobStore:
Collaboration diagram for MessageBlobStore:

Public Member Functions

 __construct (ResourceLoader $rl, ?LoggerInterface $logger, ?WANObjectCache $wanObjectCache)
 
 clear ()
 Invalidate cache keys for all known modules.
 
 getBlob (ResourceLoaderModule $module, $lang)
 Get the message blob for a module.
 
 getBlobs (array $modules, $lang)
 Get the message blobs for a set of modules.
 
 setLogger (LoggerInterface $logger)
 
 updateMessage ( $key)
 Invalidate cache keys for modules using this message key.
 

Static Public Member Functions

static clearGlobalCacheEntry (WANObjectCache $cache)
 Invalidate cache keys for all known modules.
 

Protected Member Functions

 fetchMessage ( $key, $lang)
 
 recacheMessageBlob ( $cacheKey, ResourceLoaderModule $module, $lang)
 

Protected Attributes

LoggerInterface $logger
 
WANObjectCache $wanCache
 

Private Member Functions

 generateMessageBlob (ResourceLoaderModule $module, $lang)
 Generate the message blob for a given module in a given language.
 
 makeCacheKey (ResourceLoaderModule $module, $lang)
 

Private Attributes

ResourceLoader $resourceloader
 

Detailed Description

This class generates message blobs for use by ResourceLoader.

A message blob is a JSON object containing the interface messages for a certain module in a certain language.

Since
1.17

Definition at line 38 of file MessageBlobStore.php.

Constructor & Destructor Documentation

◆ __construct()

MessageBlobStore::__construct ( ResourceLoader  $rl,
?LoggerInterface  $logger,
?WANObjectCache  $wanObjectCache 
)
Parameters
ResourceLoader$rl
LoggerInterface | null$logger
WANObjectCache | null$wanObjectCache

Definition at line 53 of file MessageBlobStore.php.

References $logger.

Member Function Documentation

◆ clear()

MessageBlobStore::clear ( )

Invalidate cache keys for all known modules.

Definition at line 178 of file MessageBlobStore.php.

◆ clearGlobalCacheEntry()

static MessageBlobStore::clearGlobalCacheEntry ( WANObjectCache  $cache)
static

Invalidate cache keys for all known modules.

Called by LocalisationCache after cache is regenerated.

Parameters
WANObjectCache$cache

Definition at line 189 of file MessageBlobStore.php.

References $cache.

Referenced by RebuildLocalisationCache\execute().

◆ fetchMessage()

MessageBlobStore::fetchMessage (   $key,
  $lang 
)
protected
Since
1.27
Parameters
string$keyMessage key
string$langLanguage code
Returns
string|null

Definition at line 206 of file MessageBlobStore.php.

References $lang, and wfMessage().

◆ generateMessageBlob()

MessageBlobStore::generateMessageBlob ( ResourceLoaderModule  $module,
  $lang 
)
private

Generate the message blob for a given module in a given language.

Parameters
ResourceLoaderModule$module
string$langLanguage code
Returns
string JSON blob

Definition at line 227 of file MessageBlobStore.php.

References $lang, ResourceLoaderModule\getMessages(), and ResourceLoaderModule\getName().

Referenced by recacheMessageBlob().

◆ getBlob()

MessageBlobStore::getBlob ( ResourceLoaderModule  $module,
  $lang 
)

Get the message blob for a module.

Since
1.27
Parameters
ResourceLoaderModule$module
string$langLanguage code
Returns
string JSON

Definition at line 84 of file MessageBlobStore.php.

References $lang, getBlobs(), and ResourceLoaderModule\getName().

◆ getBlobs()

MessageBlobStore::getBlobs ( array  $modules,
  $lang 
)

Get the message blobs for a set of modules.

Since
1.27
Parameters
ResourceLoaderModule[]$modulesArray of module objects keyed by name
string$langLanguage code
Returns
string[] An array mapping module names to message blobs

Definition at line 97 of file MessageBlobStore.php.

References $cache, $lang, $modules, $wanCache, makeCacheKey(), and recacheMessageBlob().

Referenced by getBlob().

◆ makeCacheKey()

MessageBlobStore::makeCacheKey ( ResourceLoaderModule  $module,
  $lang 
)
private
Since
1.27
Parameters
ResourceLoaderModule$module
string$lang
Returns
string Cache key

Definition at line 135 of file MessageBlobStore.php.

References $lang, ResourceLoaderModule\getMessages(), and ResourceLoaderModule\getName().

Referenced by getBlobs().

◆ recacheMessageBlob()

MessageBlobStore::recacheMessageBlob (   $cacheKey,
ResourceLoaderModule  $module,
  $lang 
)
protected
Since
1.27
Parameters
string$cacheKey
ResourceLoaderModule$module
string$lang
Returns
string JSON blob

Definition at line 150 of file MessageBlobStore.php.

References $blob, $cache, $lang, $wanCache, DB_REPLICA, generateMessageBlob(), WANObjectCache\set(), and wfGetDB().

Referenced by getBlobs().

◆ setLogger()

MessageBlobStore::setLogger ( LoggerInterface  $logger)
Since
1.27
Parameters
LoggerInterface$logger

Definition at line 72 of file MessageBlobStore.php.

References $logger.

◆ updateMessage()

MessageBlobStore::updateMessage (   $key)

Invalidate cache keys for modules using this message key.

Called by MessageCache when a message has changed.

Parameters
string$keyMessage key

Definition at line 167 of file MessageBlobStore.php.

Member Data Documentation

◆ $logger

LoggerInterface MessageBlobStore::$logger
protected

Definition at line 43 of file MessageBlobStore.php.

Referenced by __construct(), and setLogger().

◆ $resourceloader

ResourceLoader MessageBlobStore::$resourceloader
private

Definition at line 40 of file MessageBlobStore.php.

◆ $wanCache

WANObjectCache MessageBlobStore::$wanCache
protected

Definition at line 46 of file MessageBlobStore.php.

Referenced by getBlobs(), and recacheMessageBlob().


The documentation for this class was generated from the following file: