Public Member Functions | |
__construct (&$memCached, $useDB, $expiry, $memcPrefix) | |
getParserOptions () | |
ParserOptions is lazy initialised. | |
loadFromLocal ($hash, $code) | |
Try to load the cache from a local file. | |
saveToLocal ($serialized, $hash, $code) | |
Save the cache to a local file. | |
saveToScript ($array, $hash, $code) | |
escapeForScript ($string) | |
setCache ($cache, $code) | |
Set the cache to $cache, if it is valid. | |
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=false) | |
Loads cacheable messages from the database. | |
replace ($title, $text) | |
Updates cache as necessary when message page is changed. | |
lock ($key) | |
Returns success Represents a write lock on the messages key. | |
unlock ($key) | |
get ($key, $useDB=true, $langcode=true, $isFullKey=false) | |
Get a message from either the content language or the user language. | |
getMsgFromNamespace ($title, $code) | |
Get a message from the MediaWiki namespace, with caching. | |
transform ($message, $interface=false, $language=null) | |
disable () | |
enable () | |
disableTransform () | |
enableTransform () | |
setTransform ($x) | |
getTransform () | |
clear () | |
Clear all stored messages. | |
addMessage ($key, $value, $lang= 'en') | |
Add a message to the cache. | |
addMessages ($messages, $lang= 'en') | |
Add an associative array of message to the cache. | |
addMessagesByLang ($messages) | |
Add a 2-D array of messages by lang. | |
setExtensionMessagesHook ($callback) | |
Set a hook for addMessagesByLang(). | |
loadAllMessages ($lang=false) | |
loadMessagesFile ($filename, $langcode=false) | |
figureMessage ($key) | |
Public Attributes | |
$mCache | |
$mUseCache | |
$mDisable | |
$mExpiry | |
$mKeys | |
$mParserOptions | |
$mParser | |
$mLoadedLanguages = array() | |
Protected Member Functions | |
saveToCaches ($cache, $memc=true, $code=false) | |
Shortcut to update caches. |
Definition at line 20 of file MessageCache.php.
MessageCache::__construct | ( | &$ | memCached, | |
$ | useDB, | |||
$ | expiry, | |||
$ | memcPrefix | |||
) |
Definition at line 30 of file MessageCache.php.
MessageCache::addMessage | ( | $ | key, | |
$ | value, | |||
$ | lang = 'en' | |||
) |
Add a message to the cache.
mixed | $key | |
mixed | $value | |
string | $lang The messages language, English by default |
Definition at line 719 of file MessageCache.php.
References Language::getLocalisationCache(), and wfDeprecated().
MessageCache::addMessages | ( | $ | messages, | |
$ | lang = 'en' | |||
) |
Add an associative array of message to the cache.
array | $messages An associative array of key => values to be added | |
string | $lang The messages language, English by default |
Definition at line 732 of file MessageCache.php.
References $messages, Language::getLocalisationCache(), and wfDeprecated().
MessageCache::addMessagesByLang | ( | $ | messages | ) |
Add a 2-D array of messages by lang.
Useful for extensions.
array | $messages The array to be added |
Definition at line 744 of file MessageCache.php.
References $messages, Language::getLocalisationCache(), and wfDeprecated().
MessageCache::clear | ( | ) |
Clear all stored messages.
Mainly used after a mass rebuild.
Definition at line 699 of file MessageCache.php.
References $code, Language::getLanguageNames(), and wfMemcKey().
MessageCache::disable | ( | ) |
Definition at line 678 of file MessageCache.php.
MessageCache::disableTransform | ( | ) |
MessageCache::enable | ( | ) |
Definition at line 679 of file MessageCache.php.
MessageCache::enableTransform | ( | ) |
MessageCache::escapeForScript | ( | $ | string | ) |
MessageCache::figureMessage | ( | $ | key | ) |
Definition at line 769 of file MessageCache.php.
References $wgContLanguageCode, and Language::getLanguageNames().
Referenced by replace().
MessageCache::get | ( | $ | key, | |
$ | useDB = true , |
|||
$ | langcode = true , |
|||
$ | isFullKey = false | |||
) |
Get a message from either the content language or the user language.
string | $key The message cache key | |
bool | $useDB Get the message from the DB, false to use only the localisation | |
string | $langcode 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). | |
bool | $isFullKey Specifies whether $key is a two part key "msg/lang". |
Definition at line 498 of file MessageCache.php.
References $title, $wgContLang, $wgContLanguageCode, Language::getMessageFor(), getMsgFromNamespace(), and wfGetLangObj().
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.
$title | String: Message cache key with initial uppercase letter. | |
$code | String: code denoting the language to try. |
Definition at line 583 of file MessageCache.php.
References $code, $title, load(), Title::makeTitle(), Revision::newFromTitle(), wfMemcKey(), and wfRunHooks().
Referenced by get().
MessageCache::getParserOptions | ( | ) |
ParserOptions is lazy initialised.
Definition at line 44 of file MessageCache.php.
Referenced by transform().
MessageCache::getTransform | ( | ) |
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 mDisabled 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.
$code | String: language to which load messages |
Definition at line 189 of file MessageCache.php.
References $code, $success, $wgUseLocalMessageCache, loadFromDB(), loadFromLocal(), lock(), saveToCaches(), setCache(), unlock(), wfDebug(), wfMemcKey(), wfProfileIn(), and wfProfileOut().
Referenced by getMsgFromNamespace(), and replace().
MessageCache::loadAllMessages | ( | $ | lang = false |
) |
MessageCache::loadFromDB | ( | $ | code = false |
) |
Loads cacheable messages from the database.
Messages bigger than $wgMaxMsgCacheEntrySize are assigned a special value, and are loaded on-demand from the database later.
$code | Optional language code, see documenation of load(). |
Definition at line 304 of file MessageCache.php.
References $code, $dbr, $res, $wgContLanguageCode, $wgMaxMsgCacheEntrySize, Revision::getRevisionText(), wfGetDB(), wfProfileIn(), and wfProfileOut().
Referenced by load().
MessageCache::loadFromLocal | ( | $ | hash, | |
$ | code | |||
) |
Try to load the cache from a local file.
Actual format of the file depends on the $wgLocalMessageCacheSerialized setting.
$hash | String: the hash of contents, to check validity. | |
$code | Mixed: Optional language code, see documenation of load(). |
Definition at line 60 of file MessageCache.php.
References $code, $filename, $serialized, $wgCacheDirectory, $wgLocalMessageCacheSerialized, setCache(), wfRestoreWarnings(), wfSuppressWarnings(), and wfWikiID().
Referenced by load().
MessageCache::loadMessagesFile | ( | $ | filename, | |
$ | langcode = false | |||
) |
MessageCache::lock | ( | $ | key | ) |
Returns success Represents a write lock on the messages key.
Definition at line 460 of file MessageCache.php.
References $i.
MessageCache::replace | ( | $ | title, | |
$ | text | |||
) |
Updates cache as necessary when message page is changed.
$title | String: name of the page changed. | |
$text | Mixed: new contents of the page. |
Definition at line 366 of file MessageCache.php.
References $code, $parserMemc, $title, $wgMaxMsgCacheEntrySize, figureMessage(), Language::getLanguageNames(), load(), lock(), saveToCaches(), unlock(), wfMemcKey(), wfProfileIn(), wfProfileOut(), and wfRunHooks().
MessageCache::saveToCaches | ( | $ | cache, | |
$ | memc = true , |
|||
$ | code = false | |||
) | [protected] |
Shortcut to update caches.
$cache | Array: cached messages with a version. | |
$cacheKey | String: Identifier for the cache. | |
$memc | Bool: Wether to update or not memcache. | |
$code | String: Language code. |
Definition at line 428 of file MessageCache.php.
References $code, $serialized, $success, $wgLocalMessageCacheSerialized, $wgUseLocalMessageCache, saveToLocal(), saveToScript(), wfMemcKey(), wfProfileIn(), and wfProfileOut().
MessageCache::saveToLocal | ( | $ | serialized, | |
$ | hash, | |||
$ | code | |||
) |
Save the cache to a local file.
Definition at line 104 of file MessageCache.php.
References $filename, $serialized, $wgCacheDirectory, wfDebug(), wfMkdirParents(), wfRestoreWarnings(), wfSuppressWarnings(), and wfWikiID().
Referenced by saveToCaches().
MessageCache::saveToScript | ( | $ | array, | |
$ | hash, | |||
$ | code | |||
) |
Definition at line 124 of file MessageCache.php.
References $filename, $messages, $wgCacheDirectory, escapeForScript(), wfDebug(), wfMkdirParents(), wfRestoreWarnings(), wfSuppressWarnings(), and wfWikiID().
Referenced by saveToCaches().
MessageCache::setCache | ( | $ | cache, | |
$ | code | |||
) |
Set the cache to $cache, if it is valid.
Otherwise set the cache to false.
Definition at line 162 of file MessageCache.php.
References $code.
Referenced by load(), and loadFromLocal().
MessageCache::setExtensionMessagesHook | ( | $ | callback | ) |
MessageCache::setTransform | ( | $ | x | ) |
MessageCache::transform | ( | $ | message, | |
$ | interface = false , |
|||
$ | language = null | |||
) |
Definition at line 649 of file MessageCache.php.
References $language, $wgParser, $wgParserConf, and getParserOptions().
MessageCache::unlock | ( | $ | key | ) |
MessageCache::$mCache |
Definition at line 22 of file MessageCache.php.
MessageCache::$mDisable |
Definition at line 24 of file MessageCache.php.
MessageCache::$mExpiry |
Definition at line 24 of file MessageCache.php.
MessageCache::$mKeys |
Definition at line 25 of file MessageCache.php.
MessageCache::$mLoadedLanguages = array() |
Definition at line 28 of file MessageCache.php.
MessageCache::$mParser |
Definition at line 25 of file MessageCache.php.
MessageCache::$mParserOptions |
Definition at line 25 of file MessageCache.php.
MessageCache::$mUseCache |
Definition at line 24 of file MessageCache.php.