MessageCache Class Reference
[Cache]

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

List of all members.

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.


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,
memcPrefix 
)

Definition at line 30 of file MessageCache.php.


Member Function Documentation

MessageCache::addMessage ( key,
value,
lang = 'en' 
)

Add a message to the cache.

Deprecated:
Use $wgExtensionMessagesFiles
Parameters:
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.

Deprecated:
Use $wgExtensionMessagesFiles
Parameters:
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.

Deprecated:
Use $wgExtensionMessagesFiles
Parameters:
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 (  ) 

Deprecated:

Definition at line 682 of file MessageCache.php.

References wfDeprecated().

MessageCache::enable (  ) 

Definition at line 679 of file MessageCache.php.

MessageCache::enableTransform (  ) 

Definition at line 685 of file MessageCache.php.

References wfDeprecated().

MessageCache::escapeForScript ( string  ) 

Definition at line 153 of file MessageCache.php.

Referenced by saveToScript().

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.

Parameters:
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.

Parameters:
$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 (  ) 

Definition at line 691 of file MessageCache.php.

References wfDeprecated().

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.

Parameters:
$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  ) 

Deprecated:

Definition at line 760 of file MessageCache.php.

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.

Parameters:
$code Optional language code, see documenation of load().
Returns:
Array: Loaded messages for storing in caches.

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.

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

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 
)

Deprecated:

Definition at line 766 of file MessageCache.php.

MessageCache::lock ( key  ) 

Returns success Represents a write lock on the messages key.

Definition at line 460 of file MessageCache.php.

References $i.

Referenced by load(), and replace().

MessageCache::replace ( title,
text 
)

Updates cache as necessary when message page is changed.

Parameters:
$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.

Parameters:
$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.
Returns:
False on somekind of error.

Definition at line 428 of file MessageCache.php.

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

Referenced by load(), and replace().

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 
)

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  ) 

Set a hook for addMessagesByLang().

Definition at line 753 of file MessageCache.php.

MessageCache::setTransform ( x  ) 

Definition at line 688 of file MessageCache.php.

References wfDeprecated().

MessageCache::transform ( message,
interface = false,
language = null 
)

Definition at line 649 of file MessageCache.php.

References $language, $wgParser, $wgParserConf, and getParserOptions().

MessageCache::unlock ( key  ) 

Definition at line 473 of file MessageCache.php.

Referenced by load(), and replace().


Member Data Documentation

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.


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

Generated on Sat Apr 30 22:57:43 2011 for MediaWiki by  doxygen 1.5.9