MediaWiki  REL1_24
MessageBlobStore Class Reference

This class provides access to the resource message blobs storage used by the ResourceLoader. More...

List of all members.

Public Member Functions

 clear ()
 get (ResourceLoader $resourceLoader, $modules, $lang)
 Get the message blobs for a set of modules.
 insertMessageBlob ($name, ResourceLoaderModule $module, $lang)
 Generate and insert a new message blob.
 updateMessage ($key)
 Update a single message in all message blobs it occurs in.
 updateModule ($name, ResourceLoaderModule $module, $lang)
 Update the message blob for a given module in a given language.

Static Public Member Functions

static getInstance ()
 Get the singleton instance.

Private Member Functions

 generateMessageBlob (ResourceLoaderModule $module, $lang)
 Generate the message blob for a given module in a given language.
 getFromDB (ResourceLoader $resourceLoader, $modules, $lang)
 Get the message blobs for a set of modules from the database.
 getUpdatesForMessage ($key, $prevUpdates=null)
 Create an update queue for updateMessage()
 reencodeBlob ($blob, $key, $lang)
 Reencode a message blob with the updated value for a message.

Detailed Description

This class provides access to the resource message blobs storage used by the ResourceLoader.

A message blob is a JSON object containing the interface messages for a certain resource in a certain language. These message blobs are cached in the msg_resource table and automatically invalidated when one of their constituent messages or the resource itself is changed.

Definition at line 34 of file MessageBlobStore.php.


Member Function Documentation

Definition at line 258 of file MessageBlobStore.php.

References $e, wfDebug(), and wfGetDB().

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 object

Definition at line 387 of file MessageBlobStore.php.

References $key, $messages, array(), as, FormatJson\encode(), ResourceLoaderModule\getMessages(), and wfMessage().

Referenced by insertMessageBlob(), and updateModule().

MessageBlobStore::get ( ResourceLoader resourceLoader,
modules,
lang 
)

Get the message blobs for a set of modules.

Parameters:
ResourceLoader$resourceLoader
array$modulesArray of module objects keyed by module name
string$langLanguage code
Returns:
array An array mapping module names to message blobs

Definition at line 58 of file MessageBlobStore.php.

References $blob, $name, $resourceLoader, array(), as, getFromDB(), insertMessageBlob(), wfProfileIn(), and wfProfileOut().

MessageBlobStore::getFromDB ( ResourceLoader resourceLoader,
modules,
lang 
) [private]

Get the message blobs for a set of modules from the database.

Modules whose blobs are not in the database are silently dropped.

Parameters:
ResourceLoader$resourceLoader
array$modulesArray of module names
string$langLanguage code
Exceptions:
MWException
Returns:
array Array mapping module names to blobs

Definition at line 347 of file MessageBlobStore.php.

References $dbr, $keys, $res, $retval, array(), as, FormatJson\decode(), ResourceLoader\getConfig(), ResourceLoader\getModule(), updateModule(), wfGetDB(), and wfTimestamp().

Referenced by get().

static MessageBlobStore::getInstance ( ) [static]

Get the singleton instance.

Since:
1.24
Returns:
MessageBlobStore

Definition at line 41 of file MessageBlobStore.php.

MessageBlobStore::getUpdatesForMessage ( key,
prevUpdates = null 
) [private]

Create an update queue for updateMessage()

Parameters:
string$keyMessage key
array$prevUpdatesUpdates queue to refresh or null to build a fresh update queue
Returns:
array Updates queue

Definition at line 278 of file MessageBlobStore.php.

References $key, $res, array(), as, and wfGetDB().

Referenced by updateMessage().

MessageBlobStore::insertMessageBlob ( name,
ResourceLoaderModule module,
lang 
)

Generate and insert a new message blob.

If the blob was already present, it is not regenerated; instead, the preexisting blob is fetched and returned.

Parameters:
string$nameModule name
ResourceLoaderModule$module
string$langLanguage code
Returns:
mixed Message blob or false if the module has no messages

Definition at line 90 of file MessageBlobStore.php.

References $blob, $e, $key, $name, $success, array(), as, generateMessageBlob(), ResourceLoaderModule\getMessages(), wfDebug(), and wfGetDB().

Referenced by get().

MessageBlobStore::reencodeBlob ( blob,
key,
lang 
) [private]

Reencode a message blob with the updated value for a message.

Parameters:
string$blobMessage blob (JSON object)
string$keyMessage key
string$langLanguage code
Returns:
string Message blob with $key replaced with its new value

Definition at line 330 of file MessageBlobStore.php.

References $blob, $key, FormatJson\decode(), FormatJson\encode(), and wfMessage().

Update a single message in all message blobs it occurs in.

Parameters:
string$keyMessage key

Definition at line 215 of file MessageBlobStore.php.

References $e, $key, $success, array(), as, getUpdatesForMessage(), wfDebug(), and wfGetDB().

MessageBlobStore::updateModule ( name,
ResourceLoaderModule module,
lang 
)

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

Parameters:
string$nameModule name
ResourceLoaderModule$module
string$langLanguage code
Returns:
string Regenerated message blob, or null if there was no blob for the given module/language pair.

Definition at line 148 of file MessageBlobStore.php.

References $e, $name, array(), as, FormatJson\decode(), generateMessageBlob(), wfDebug(), and wfGetDB().

Referenced by getFromDB().


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