MediaWiki  REL1_21
MessageCache Class Reference

Message cache Performs various MediaWiki namespace-related functions. More...

List of all members.

Public Member Functions

 __construct ($memCached, $useDB, $expiry)
 clear ()
 Clear all stored messages.
 disable ()
 enable ()
 escapeForScript ($string)
 figureMessage ($key)
 get ($key, $useDB=true, $langcode=true, $isFullKey=false)
 Get a message from either the content language or the user language.
 getAllMessageKeys ($code)
 Get all message keys stored in the message cache for a given language.
 getMsgFromNamespace ($title, $code)
 Get a message from the MediaWiki namespace, with caching.
 getParser ()
 getParserOptions ()
 ParserOptions is lazy initialised.
 load ($code=false)
 Loads messages from caches or from database in this order: (1) local message cache (if $wgUseLocalMessageCache is enabled) (2) memcached (3) from the database.
 loadFromDB ($code)
 Loads cacheable messages from the database.
 loadFromLocal ($hash, $code)
 Try to load the cache from a local file.
 lock ($key)
 Represents a write lock on the messages key.
 parse ($text, $title=null, $linestart=true, $interface=false, $language=null)
 replace ($title, $text)
 Updates cache as necessary when message page is changed.
 saveToLocal ($serialized, $hash, $code)
 Save the cache to a local file.
 saveToScript ($array, $hash, $code)
 setCache ($cache, $code)
 Set the cache to $cache, if it is valid.
 transform ($message, $interface=false, $language=null, $title=null)
 unlock ($key)

Static Public Member Functions

static destroyInstance ()
 Destroy the singleton instance.
static singleton ()
 Get the signleton instance of this class.

Public Attributes

 $mParser

Protected Member Functions

 saveToCaches ($cache, $memc=true, $code=false)
 Shortcut to update caches.

Protected Attributes

 $mCache
 Process local cache of loaded messages that are defined in MediaWiki namespace.
 $mDisable
 $mExpiry
 Lifetime for cache, used by object caching.
bool $mInParser = false
 $mLoadedLanguages = array()
 Variable for tracking which variables are already loaded.
 $mParserOptions
 Message cache has it's own parser which it uses to transform messages.

Static Private Attributes

static $instance

Detailed Description

Message cache Performs various MediaWiki namespace-related functions.

Definition at line 37 of file MessageCache.php.


Constructor & Destructor Documentation

MessageCache::__construct ( memCached,
useDB,
expiry 
)

Definition at line 96 of file MessageCache.php.

References wfGetCache().


Member Function Documentation

Clear all stored messages.

Mainly used after a mass rebuild.

Definition at line 885 of file MessageCache.php.

static MessageCache::destroyInstance ( ) [static]

Destroy the singleton instance.

Since:
1.18

Definition at line 92 of file MessageCache.php.

Referenced by NewParserTest\setupGlobals().

Definition at line 874 of file MessageCache.php.

Definition at line 878 of file MessageCache.php.

Definition at line 223 of file MessageCache.php.

Referenced by saveToScript().

Parameters:
$key
Returns:
array

Definition at line 900 of file MessageCache.php.

MessageCache::get ( key,
useDB = true,
langcode = true,
isFullKey = false 
)

Get a message from either the content language or the user language.

Parameters:
string$keythe message cache key
$useDBBoolean: get the message from the DB, false to use only the localisation
bool | string$langcodeCode of the language to get the message for, if it is a valid code create a language for that language, if it is a string but not a valid code then make a basic language object, if it is a false boolean then use the current users language (as a fallback for the old parameter functionality), or if it is a true boolean then use the wikis content language (also as a fallback).
$isFullKeyBoolean: specifies whether $key is a two part key "msg/lang".
Exceptions:
MWException
Returns:
string|bool

Definition at line 607 of file MessageCache.php.

Get all message keys stored in the message cache for a given language.

If $code is the content language code, this will return all message keys for which MediaWiki:msgkey exists. If $code is another language code, this will ONLY return message keys for which MediaWiki:msgkey/$code exists.

Parameters:
$codestring
Returns:
array of message keys (strings)

Definition at line 924 of file MessageCache.php.

MessageCache::getMsgFromNamespace ( title,
code 
)

Get a message from the MediaWiki namespace, with caching.

The key must first be converted to two-part lang/msg form if necessary.

Parameters:
string$titleMessage cache key with initial uppercase letter.
string$codecode denoting the language to try.
Returns:
string|bool False on failure

Definition at line 708 of file MessageCache.php.

Returns:
Parser

Definition at line 819 of file MessageCache.php.

ParserOptions is lazy initialised.

Returns:
ParserOptions

Definition at line 111 of file MessageCache.php.

MessageCache::load ( code = false)

Loads messages from caches or from database in this order: (1) local message cache (if $wgUseLocalMessageCache is enabled) (2) memcached (3) from the database.

When succesfully loading from (2) or (3), all higher level caches are updated for the newest version.

Nothing is loaded if member variable mDisable is true, either manually set by calling code or if message loading fails (is this possible?).

Returns true if cache is already populated or it was succesfully populated, or false if populating empty cache fails. Also returns true if MessageCache is disabled.

Parameters:
bool | String$codeString: language to which load messages
Exceptions:
MWException
Returns:
bool

Definition at line 263 of file MessageCache.php.

Loads cacheable messages from the database.

Messages bigger than $wgMaxMsgCacheEntrySize are assigned a special value, and are loaded on-demand from the database later.

Parameters:
string$codelanguage code.
Returns:
Array: loaded messages for storing in caches.

Definition at line 393 of file MessageCache.php.

MessageCache::loadFromLocal ( hash,
code 
)

Try to load the cache from a local file.

Actual format of the file depends on the $wgLocalMessageCacheSerialized setting.

Parameters:
string$hashthe hash of contents, to check validity.
$codeMixed: Optional language code, see documenation of load().
Returns:
bool on failure.

Definition at line 128 of file MessageCache.php.

MessageCache::lock ( key)

Represents a write lock on the messages key.

Parameters:
$keystring
Returns:
Boolean: success

Definition at line 573 of file MessageCache.php.

MessageCache::parse ( text,
title = null,
linestart = true,
interface = false,
language = null 
)
Parameters:
$textstring
$titleTitle
$linestartbool
$interfacebool
$language
Returns:
ParserOutput|string

Definition at line 844 of file MessageCache.php.

MessageCache::replace ( title,
text 
)

Updates cache as necessary when message page is changed.

Parameters:
string$titlename of the page changed.
$textMixed: new contents of the page.

Definition at line 473 of file MessageCache.php.

MessageCache::saveToCaches ( cache,
memc = true,
code = false 
) [protected]

Shortcut to update caches.

Parameters:
array$cachecached messages with a version.
bool$memcWether to update or not memcache.
string$codeLanguage code.
Returns:
bool on somekind of error.

Definition at line 538 of file MessageCache.php.

MessageCache::saveToLocal ( serialized,
hash,
code 
)

Save the cache to a local file.

Definition at line 172 of file MessageCache.php.

MessageCache::saveToScript ( array,
hash,
code 
)
MessageCache::setCache ( cache,
code 
)

Set the cache to $cache, if it is valid.

Otherwise set the cache to false.

Returns:
bool

Definition at line 234 of file MessageCache.php.

MessageCache::transform ( message,
interface = false,
language = null,
title = null 
)
Parameters:
$messagestring
$interfacebool
$language
$titleTitle
Returns:
string

Definition at line 791 of file MessageCache.php.

Definition at line 582 of file MessageCache.php.


Member Data Documentation

MessageCache::$instance [static, private]

Definition at line 67 of file MessageCache.php.

MessageCache::$mCache [protected]

Process local cache of loaded messages that are defined in MediaWiki namespace.

First array level is a language code, second level is message key and the values are either message content prefixed with space, or !NONEXISTENT for negative caching.

Definition at line 45 of file MessageCache.php.

MessageCache::$mDisable [protected]

Definition at line 48 of file MessageCache.php.

MessageCache::$mExpiry [protected]

Lifetime for cache, used by object caching.

Definition at line 51 of file MessageCache.php.

bool MessageCache::$mInParser = false [protected]

Definition at line 71 of file MessageCache.php.

MessageCache::$mLoadedLanguages = array() [protected]

Variable for tracking which variables are already loaded.

Definition at line 60 of file MessageCache.php.

MessageCache::$mParser

Definition at line 57 of file MessageCache.php.

MessageCache::$mParserOptions [protected]

Message cache has it's own parser which it uses to transform messages.

Definition at line 57 of file MessageCache.php.


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