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 $wgLocalMessageCache 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 ()
 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.
 getExtensionMessagesFor ($lang= 'en')
 Get the extension messages for a specific language.
 clear ()
 Clear all stored messages.
 loadAllMessages ($lang=false)
 loadMessagesFile ($filename, $langcode=false)
 Load messages from a given file.
 processMessagesArray ($messages, $langcode)
 Process an array of messages, loading it into the message cache.
 figureMessage ($key)

Public Attributes

 $mCache
 $mUseCache
 $mDisable
 $mExpiry
 $mKeys
 $mParserOptions
 $mParser
 $mExtensionMessages = array()
 $mInitialised = false
 $mAllMessagesLoaded = array()
 $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 33 of file MessageCache.php.


Member Function Documentation

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

Add a message to the cache.

Parameters:
mixed $key
mixed $value
string $lang The messages language, English by default

Definition at line 704 of file MessageCache.php.

References $key, and $wgContLang.

MessageCache::addMessages ( messages,
lang = 'en' 
)

Add an associative array of message to the cache.

Parameters:
array $messages An associative array of key => values to be added
string $lang The messages language, English by default

Definition at line 717 of file MessageCache.php.

References $messages, wfProfileIn(), and wfProfileOut().

Referenced by addMessagesByLang(), and processMessagesArray().

MessageCache::addMessagesByLang ( messages  ) 

Add a 2-D array of messages by lang.

Useful for extensions.

Parameters:
array $messages The array to be added

Definition at line 735 of file MessageCache.php.

References $key, $messages, addMessages(), wfProfileIn(), and wfProfileOut().

MessageCache::clear (  ) 

Clear all stored messages.

Mainly used after a mass rebuild.

Definition at line 765 of file MessageCache.php.

References $code, $langs, Language::getLanguageNames(), and wfMemcKey().

MessageCache::disable (  ) 

Definition at line 679 of file MessageCache.php.

MessageCache::disableTransform (  ) 

Deprecated:

Definition at line 683 of file MessageCache.php.

References wfDeprecated().

MessageCache::enable (  ) 

Definition at line 680 of file MessageCache.php.

MessageCache::enableTransform (  ) 

Definition at line 686 of file MessageCache.php.

References wfDeprecated().

MessageCache::escapeForScript ( string  ) 

Definition at line 157 of file MessageCache.php.

Referenced by saveToScript().

MessageCache::figureMessage ( key  ) 

Definition at line 854 of file MessageCache.php.

References $key, $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 "lang/msg".

Definition at line 503 of file MessageCache.php.

References $code, $key, $title, $wgContLang, $wgContLanguageCode, Language::getLanguageNames(), Language::getMessageFor(), getMsgFromNamespace(), and wfGetLangObj().

MessageCache::getExtensionMessagesFor ( lang = 'en'  ) 

Get the extension messages for a specific language.

Only English, interface and content language are guaranteed to be loaded.

Parameters:
string $lang The messages language, English by default

Definition at line 749 of file MessageCache.php.

References $messages, wfProfileIn(), and wfProfileOut().

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

References $code, $revision, $title, $type, load(), Title::makeTitle(), Revision::newFromTitle(), wfMemcKey(), and wfRunHooks().

Referenced by get().

MessageCache::getParserOptions (  ) 

ParserOptions is lazy initialised.

Definition at line 48 of file MessageCache.php.

Referenced by transform().

MessageCache::getTransform (  ) 

Definition at line 692 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 $wgLocalMessageCache 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 193 of file MessageCache.php.

References $code, $success, $wgLocalMessageCache, 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.

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

Definition at line 308 of file MessageCache.php.

References $code, $conds, $dbr, $res, $row, $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 64 of file MessageCache.php.

References $code, $file, $filename, $serialized, $wgLocalMessageCache, $wgLocalMessageCacheSerialized, setCache(), wfRestoreWarnings(), wfSuppressWarnings(), and wfWikiID().

Referenced by load().

MessageCache::loadMessagesFile ( filename,
langcode = false 
)

Load messages from a given file.

Parameters:
string $filename Filename of file to load.
string $langcode Language to load messages for, or false for default behvaiour (en, content language and user language).

Definition at line 804 of file MessageCache.php.

References $code, $filename, $langs, $magicWords, $messages, $wgContLang, $wgLang, Language::getLanguageNames(), processMessagesArray(), wfDebug(), wfProfileIn(), and wfProfileOut().

MessageCache::lock ( key  ) 

Returns success Represents a write lock on the messages key.

Definition at line 465 of file MessageCache.php.

References $i, and $key.

Referenced by load(), and replace().

MessageCache::processMessagesArray ( messages,
langcode 
)

Process an array of messages, loading it into the message cache.

Parameters:
array $messages Messages array.
string $langcode Language code to process.

Definition at line 838 of file MessageCache.php.

References $messages, addMessages(), wfProfileIn(), and wfProfileOut().

Referenced by loadMessagesFile().

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

References $code, $parserMemc, $text, $title, $wgMaxMsgCacheEntrySize, figureMessage(), load(), lock(), saveToCaches(), unlock(), wfMemcKey(), wfProfileIn(), and wfProfileOut().

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

References $code, $i, $serialized, $success, $wgLocalMessageCache, $wgLocalMessageCacheSerialized, 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 108 of file MessageCache.php.

References $file, $filename, $serialized, $wgLocalMessageCache, 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 166 of file MessageCache.php.

References $code.

Referenced by load(), and loadFromLocal().

MessageCache::setTransform ( x  ) 

Definition at line 689 of file MessageCache.php.

References wfDeprecated().

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

Definition at line 650 of file MessageCache.php.

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

MessageCache::unlock ( key  ) 

Definition at line 478 of file MessageCache.php.

References $key.

Referenced by load(), and replace().


Member Data Documentation

MessageCache::$mAllMessagesLoaded = array()

Definition at line 28 of file MessageCache.php.

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::$mExtensionMessages = array()

Definition at line 26 of file MessageCache.php.

MessageCache::$mInitialised = false

Definition at line 27 of file MessageCache.php.

MessageCache::$mKeys

Definition at line 25 of file MessageCache.php.

MessageCache::$mLoadedLanguages = array()

Definition at line 31 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 Sep 5 02:08:42 2009 for MediaWiki by  doxygen 1.5.9