MediaWiki  REL1_19
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.
 getMostUsedMessages ()
 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 logMessages ()
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.
 $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.
 $mRequestedMessages = array()
 Used for automatic detection of most used messages.

Static Protected Attributes

static $mAdaptiveDataAge = 604800
 How long the message request counts are stored.
static $mAdaptiveInclusionThreshold = 0.05
 Filter the tail of less used messages that are requested more seldom than this factor times the number of request of most requested message.

Static Private Attributes

static $instance

Detailed Description

Message cache Performs various MediaWiki namespace-related functions.

Definition at line 20 of file MessageCache.php.


Constructor & Destructor Documentation

MessageCache::__construct ( memCached,
useDB,
expiry 
)

Definition at line 100 of file MessageCache.php.

References wfGetCache().

Here is the call graph for this function:


Member Function Documentation

Clear all stored messages.

Mainly used after a mass rebuild.

Definition at line 870 of file MessageCache.php.

References Language\getLanguageNames(), and wfMemcKey().

Here is the call graph for this function:

static MessageCache::destroyInstance ( ) [static]

Destroy the singleton instance.

Since:
1.18

Definition at line 96 of file MessageCache.php.

Definition at line 859 of file MessageCache.php.

Definition at line 863 of file MessageCache.php.

Definition at line 226 of file MessageCache.php.

Referenced by saveToScript().

Here is the caller graph for this function:

Parameters:
$key
Returns:
array

Definition at line 885 of file MessageCache.php.

References $wgLanguageCode, and Language\getLanguageNames().

Referenced by replace().

Here is the call graph for this function:

Here is the caller graph for this function:

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

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

Parameters:
$keyString: the message cache key
$useDBBoolean: get the message from the DB, false to use only the localisation
$langcodeString: code 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".
Returns:
string|false

Definition at line 593 of file MessageCache.php.

References $title, $wgContLang, $wgLanguageCode, Language\getMessageFor(), getMsgFromNamespace(), and wfGetLangObj().

Here is the call graph for this function:

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 986 of file MessageCache.php.

References $wgContLang, and load().

Here is the call graph for this function:

Returns:
array

Definition at line 945 of file MessageCache.php.

References $count, $messages, wfGetCache(), wfMemcKey(), wfProfileIn(), and wfProfileOut().

Referenced by loadFromDB().

Here is the call graph for this function:

Here is the caller graph for this function:

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:
$titleString: Message cache key with initial uppercase letter.
$codeString: code denoting the language to try.
Returns:
string|false

Definition at line 701 of file MessageCache.php.

References $title, $wgAdaptiveMessageCache, load(), Title\makeTitle(), Revision\newFromTitle(), wfDebugLog(), wfMemcKey(), and wfRunHooks().

Referenced by get().

Here is the call graph for this function:

Here is the caller graph for this function:

Returns:
Parser

Definition at line 804 of file MessageCache.php.

References $wgParser, and $wgParserConf.

Referenced by parse(), and transform().

Here is the caller graph for this function:

ParserOptions is lazy initialised.

Returns:
ParserOptions

Definition at line 115 of file MessageCache.php.

Referenced by parse(), and transform().

Here is the caller graph for this function:

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:
$codeString: language to which load messages

Definition at line 264 of file MessageCache.php.

References $success, $wgUseLocalMessageCache, loadFromDB(), loadFromLocal(), lock(), saveToCaches(), setCache(), unlock(), wfDebug(), wfMemcKey(), wfProfileIn(), and wfProfileOut().

Referenced by getAllMessageKeys(), getMsgFromNamespace(), and replace().

Here is the call graph for this function:

Here is the caller graph for this function:

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:
$codeString: language code.
Returns:
Array: loaded messages for storing in caches.

Definition at line 375 of file MessageCache.php.

References $dbr, $res, $wgAdaptiveMessageCache, $wgLanguageCode, $wgMaxMsgCacheEntrySize, getMostUsedMessages(), Revision\getRevisionText(), wfDebugLog(), wfGetDB(), wfProfileIn(), and wfProfileOut().

Referenced by load().

Here is the call graph for this function:

Here is the caller graph for this function:

MessageCache::loadFromLocal ( hash,
code 
)

Try to load the cache from a local file.

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

Parameters:
$hashString: the hash of contents, to check validity.
$codeMixed: Optional language code, see documenation of load().
Returns:
false on failure.

Definition at line 131 of file MessageCache.php.

References $file, $serialized, $wgCacheDirectory, $wgLocalMessageCacheSerialized, setCache(), wfRestoreWarnings(), wfSuppressWarnings(), and wfWikiID().

Referenced by load().

Here is the call graph for this function:

Here is the caller graph for this function:

MessageCache::lock ( key)

Represents a write lock on the messages key.

Parameters:
$keystring
Returns:
Boolean: success

Definition at line 560 of file MessageCache.php.

Referenced by load(), and replace().

Here is the caller graph for this function:

static MessageCache::logMessages ( ) [static]

Definition at line 902 of file MessageCache.php.

References $mAdaptiveDataAge, $wgAdaptiveMessageCache, wfGetCache(), wfProfileIn(), wfProfileOut(), wfTimestamp(), and wfTimestampNow().

Referenced by MediaWiki\restInPeace().

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 829 of file MessageCache.php.

References $language, $res, $title, $wgTitle, getParser(), getParserOptions(), Title\newFromText(), wfProfileIn(), and wfProfileOut().

Here is the call graph for this function:

MessageCache::replace ( title,
text 
)

Updates cache as necessary when message page is changed.

Parameters:
$titleString: name of the page changed.
$textMixed: new contents of the page.

Definition at line 460 of file MessageCache.php.

References $title, $wgContLang, $wgMaxMsgCacheEntrySize, $wgMemc, figureMessage(), Language\getLanguageNames(), load(), lock(), saveToCaches(), unlock(), MessageBlobStore\updateMessage(), wfMemcKey(), wfProfileIn(), wfProfileOut(), and wfRunHooks().

Here is the call graph for this function:

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

Shortcut to update caches.

Parameters:
$cacheArray: cached messages with a version.
$memcBool: Wether to update or not memcache.
$codeString: Language code.
Returns:
False on somekind of error.

Definition at line 525 of file MessageCache.php.

References $serialized, $success, $wgLocalMessageCacheSerialized, $wgUseLocalMessageCache, saveToLocal(), saveToScript(), wfMemcKey(), wfProfileIn(), and wfProfileOut().

Referenced by load(), and replace().

Here is the call graph for this function:

Here is the caller graph for this function:

MessageCache::saveToLocal ( serialized,
hash,
code 
)

Save the cache to a local file.

Definition at line 175 of file MessageCache.php.

References $file, $serialized, $wgCacheDirectory, wfDebug(), wfMkdirParents(), wfRestoreWarnings(), wfSuppressWarnings(), and wfWikiID().

Referenced by saveToCaches().

Here is the call graph for this function:

Here is the caller graph for this function:

MessageCache::saveToScript ( array,
hash,
code 
)

Definition at line 197 of file MessageCache.php.

References $file, $wgCacheDirectory, escapeForScript(), wfDebug(), wfMkdirParents(), wfRestoreWarnings(), wfSuppressWarnings(), and wfWikiID().

Referenced by saveToCaches().

Here is the call graph for this function:

Here is the caller graph for this function:

MessageCache::setCache ( cache,
code 
)

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

Otherwise set the cache to false.

Returns:
bool

Definition at line 237 of file MessageCache.php.

Referenced by load(), and loadFromLocal().

Here is the caller graph for this function:

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

Definition at line 776 of file MessageCache.php.

References $language, $title, getParser(), and getParserOptions().

Here is the call graph for this function:

Definition at line 569 of file MessageCache.php.

Referenced by load(), and replace().

Here is the caller graph for this function:


Member Data Documentation

MessageCache::$instance [static, private]

Definition at line 70 of file MessageCache.php.

Referenced by singleton().

MessageCache::$mAdaptiveDataAge = 604800 [static, protected]

How long the message request counts are stored.

Longer period gives better sample, but also takes longer to adapt changes. The counts are aggregrated per day, regardless of the value of this variable.

Definition at line 55 of file MessageCache.php.

Referenced by logMessages().

MessageCache::$mAdaptiveInclusionThreshold = 0.05 [static, protected]

Filter the tail of less used messages that are requested more seldom than this factor times the number of request of most requested message.

These messages are not loaded in the default set, but are still cached individually on demand with the normal cache expiry time.

Definition at line 63 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 28 of file MessageCache.php.

MessageCache::$mDisable [protected]

Definition at line 31 of file MessageCache.php.

MessageCache::$mExpiry [protected]

Lifetime for cache, used by object caching.

Definition at line 34 of file MessageCache.php.

MessageCache::$mInParser = false [protected]

Definition at line 75 of file MessageCache.php.

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

Variable for tracking which variables are already loaded.

Definition at line 43 of file MessageCache.php.

MessageCache::$mParser

Definition at line 40 of file MessageCache.php.

MessageCache::$mParserOptions [protected]

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

Definition at line 40 of file MessageCache.php.

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

Used for automatic detection of most used messages.

Definition at line 48 of file MessageCache.php.


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