MediaWiki  1.23.2
MessageBlobStore Class Reference

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

Static Public Member Functions

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

Static Private Member Functions

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

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

◆ clear()

static MessageBlobStore::clear ( )
static

Definition at line 243 of file MessageBlobStore.php.

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

Referenced by DatabaseUpdater\purgeCache(), and LocalisationCache\recache().

◆ generateMessageBlob()

static MessageBlobStore::generateMessageBlob ( ResourceLoaderModule  $module,
  $lang 
)
staticprivate

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

Parameters
$moduleResourceLoaderModule object
string$langlanguage code
Returns
String: JSON object

Definition at line 368 of file MessageBlobStore.php.

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

Referenced by insertMessageBlob(), and updateModule().

◆ get()

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

Get the message blobs for a set of modules.

Parameters
$resourceLoaderResourceLoader object
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 44 of file MessageBlobStore.php.

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

Referenced by ResourceLoader\makeModuleResponse().

◆ getFromDB()

static MessageBlobStore::getFromDB ( ResourceLoader  $resourceLoader,
  $modules,
  $lang 
)
staticprivate

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

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

Parameters
$resourceLoaderResourceLoader object
array$modulesof module names
string$langlanguage code
Exceptions
MWException
Returns
array Array mapping module names to blobs

Definition at line 332 of file MessageBlobStore.php.

References $dbr, $res, $resourceLoader, $retval, array(), as, DB_SLAVE, FormatJson\decode(), global, TS_MW, updateModule(), wfGetDB(), and wfTimestamp().

Referenced by get().

◆ getUpdatesForMessage()

static MessageBlobStore::getUpdatesForMessage (   $key,
  $prevUpdates = null 
)
staticprivate

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 263 of file MessageBlobStore.php.

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

Referenced by updateMessage().

◆ insertMessageBlob()

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

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
$moduleResourceLoaderModule object
string$langlanguage code
Returns
mixed Message blob or false if the module has no messages

Definition at line 76 of file MessageBlobStore.php.

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

Referenced by get().

◆ reencodeBlob()

static MessageBlobStore::reencodeBlob (   $blob,
  $key,
  $lang 
)
staticprivate

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

Parameters
string$blobmessage blob (JSON object)
string$keymessage key
string$langlanguage code
Returns
Message blob with $key replaced with its new value

Definition at line 315 of file MessageBlobStore.php.

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

◆ updateMessage()

static MessageBlobStore::updateMessage (   $key)
static

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

Parameters
string$keymessage key

Definition at line 200 of file MessageBlobStore.php.

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

Referenced by MessageCache\replace().

◆ updateModule()

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

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

Parameters
string$namemodule name
$moduleResourceLoaderModule object
string$langlanguage code
Returns
String Regenerated message blob, or null if there was no blob for the given module/language pair

Definition at line 133 of file MessageBlobStore.php.

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

Referenced by getFromDB().


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