[ Index ]

PHP Cross Reference of MediaWiki-1.24.0

title

Body

[close]

/includes/cache/ -> MessageCache.php (summary)

Localisation messages cache. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

File Size: 1148 lines (33 kb)
Included or required:0 times
Referenced: 1 time
Includes or requires: 0 files

Defines 1 class

MessageCache:: (24 methods):
  singleton()
  destroyInstance()
  __construct()
  getParserOptions()
  getLocalCache()
  saveToLocal()
  load()
  loadFromDB()
  replace()
  isCacheExpired()
  saveToCaches()
  lock()
  unlock()
  get()
  getMessageFromFallbackChain()
  getMsgFromNamespace()
  transform()
  getParser()
  parse()
  disable()
  enable()
  clear()
  figureMessage()
  getAllMessageKeys()


Class: MessageCache  - X-Ref

Message cache
Performs various MediaWiki namespace-related functions

singleton()   X-Ref
Get the signleton instance of this class

return: MessageCache

destroyInstance()   X-Ref
Destroy the singleton instance


__construct( $memCached, $useDB, $expiry )   X-Ref

param: BagOStuff $memCached A cache instance. If none, fall back to CACHE_NONE.
param: bool $useDB
param: int $expiry Lifetime for cache. @see $mExpiry.

getParserOptions()   X-Ref
ParserOptions is lazy initialised.

return: ParserOptions

getLocalCache( $hash, $code )   X-Ref
Try to load the cache from a local file.

param: string $hash The hash of contents, to check validity.
param: string $code Optional language code, see documenation of load().
return: array The cache array

saveToLocal( $serialized, $hash, $code )   X-Ref
Save the cache to a local file.

param: string $serialized
param: string $hash
param: string $code

load( $code = false )   X-Ref
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.

param: bool|string $code Language to which load messages
return: bool

loadFromDB( $code )   X-Ref
Loads cacheable messages from the database. Messages bigger than
$wgMaxMsgCacheEntrySize are assigned a special value, and are loaded
on-demand from the database later.

param: string $code Language code.
return: array Loaded messages for storing in caches.

replace( $title, $text )   X-Ref
Updates cache as necessary when message page is changed

param: string $title Name of the page changed.
param: mixed $text New contents of the page.

isCacheExpired( $cache )   X-Ref
Is the given cache array expired due to time passing or a version change?

param: array $cache
return: bool

saveToCaches( $cache, $dest, $code = false )   X-Ref
Shortcut to update caches.

param: array $cache Cached messages with a version.
param: string $dest Either "local-only" to save to local caches only
param: string|bool $code Language code (default: false)
return: bool

lock( $key )   X-Ref
Represents a write lock on the messages key.

Will retry MessageCache::MSG_WAIT_TIMEOUT times, each operations having
a timeout of MessageCache::MSG_LOCK_TIMEOUT.

param: string $key
return: bool Success

unlock( $key )   X-Ref
No description

get( $key, $useDB = true, $langcode = true, $isFullKey = false )   X-Ref
Get a message from either the content language or the user language.

First, assemble a list of languages to attempt getting the message from. This
chain begins with the requested language and its fallbacks and then continues with
the content language and its fallbacks. For each language in the chain, the following
process will occur (in this order):
1. If a language-specific override, i.e., [[MW:msg/lang]], is available, use that.
Note: for the content language, there is no /lang subpage.
2. Fetch from the static CDB cache.
3. If available, check the database for fallback language overrides.

This process provides a number of guarantees. When changing this code, make sure all
of these guarantees are preserved.
* If the requested language is *not* the content language, then the CDB cache for that
specific language will take precedence over the root database page ([[MW:msg]]).
* Fallbacks will be just that: fallbacks. A fallback language will never be reached if
the message is available *anywhere* in the language for which it is a fallback.

param: string $key The message key
param: bool $useDB If true, look for the message in the DB, false
param: bool|string|object $langcode Code of the language to get the message for.
param: bool $isFullKey Specifies whether $key is a two part key "msg/lang".
return: string|bool False if the message doesn't exist, otherwise the

getMessageFromFallbackChain( $lang, $lckey, $uckey, $useDB )   X-Ref
Given a language, try and fetch a message from that language, then the
fallbacks of that language, then the site language, then the fallbacks for the
site language.

param: Language $lang Requested language
param: string $lckey Lowercase key for the message
param: string $uckey Uppercase key for the message
param: bool $useDB Whether to use the database
return: string|bool The message, or false if not found

getMsgFromNamespace( $title, $code )   X-Ref
Get a message from the MediaWiki namespace, with caching. The key must
first be converted to two-part lang/msg form if necessary.

Unlike self::get(), this function doesn't resolve fallback chains, and
some callers require this behavior. LanguageConverter::parseCachedTable()
and self::get() are some examples in core.

param: string $title Message cache key with initial uppercase letter.
param: string $code Code denoting the language to try.
return: string|bool The message, or false if it does not exist or on error

transform( $message, $interface = false, $language = null, $title = null )   X-Ref

param: string $message
param: bool $interface
param: string $language Language code
param: Title $title
return: string

getParser()   X-Ref

return: Parser

parse( $text, $title = null, $linestart = true,$interface = false, $language = null)   X-Ref

param: string $text
param: Title $title
param: bool $linestart Whether or not this is at the start of a line
param: bool $interface Whether this is an interface message
param: string $language Language code
return: ParserOutput|string

disable()   X-Ref
No description

enable()   X-Ref
No description

clear()   X-Ref
Clear all stored messages. Mainly used after a mass rebuild.


figureMessage( $key )   X-Ref

param: string $key
return: array

getAllMessageKeys( $code )   X-Ref
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.

param: string $code Language code
return: array Array of message keys (strings)



Generated: Fri Nov 28 14:03:12 2014 Cross-referenced by PHPXref 0.7.1