MediaWiki master
|
Cache messages that are defined by MediaWiki-namespace pages or by hooks. More...
Inherits LoggerAwareInterface.
Public Member Functions | |
__construct (WANObjectCache $wanCache, BagOStuff $clusterCache, BagOStuff $serverCache, Language $contLang, LanguageConverterFactory $langConverterFactory, LoggerInterface $logger, ServiceOptions $options, LanguageFactory $langFactory, LocalisationCache $localisationCache, LanguageNameUtils $languageNameUtils, LanguageFallback $languageFallback, HookContainer $hookContainer, ParserFactory $parserFactory) | |
clear () | |
Clear all stored messages in global and local cache. | |
disable () | |
enable () | |
figureMessage ( $key) | |
get ( $key, $useDB=true, $language=null, &$usedKey='') | |
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. | |
getCheckKey ( $code) | |
getMsgFromNamespace ( $title, $code) | |
Get a message from the MediaWiki namespace, with caching. | |
isDisabled () | |
Whether DB/cache usage is disabled for determining messages. | |
parse ( $text, ?PageReference $page=null, $linestart=true, $interface=false, $language=null) | |
parseWithPostprocessing (string $text, PageReference $contextPage, bool $linestart=true, bool $interface=false, $language=null) | |
refreshAndReplaceInternal (string $code, array $replacements) | |
replace ( $title, $text) | |
Updates cache as necessary when message page is changed. | |
setLogger (LoggerInterface $logger) | |
transform ( $message, $interface=false, $language=null, ?PageReference $page=null) | |
updateMessageOverride ( $page, ?Content $content=null) | |
Purge message caches when a MediaWiki: page is created, updated, or deleted. | |
Static Public Member Functions | |
static | normalizeKey ( $key) |
Normalize message key input. | |
Public Attributes | |
const | CONSTRUCTOR_OPTIONS |
Options to be included in the ServiceOptions. | |
const | MAX_REQUEST_LANGUAGES = 10 |
The size of the MapCacheLRU which stores message data. | |
Cache messages that are defined by MediaWiki-namespace pages or by hooks.
Definition at line 72 of file MessageCache.php.
MessageCache::__construct | ( | WANObjectCache | $wanCache, |
BagOStuff | $clusterCache, | ||
BagOStuff | $serverCache, | ||
Language | $contLang, | ||
LanguageConverterFactory | $langConverterFactory, | ||
LoggerInterface | $logger, | ||
ServiceOptions | $options, | ||
LanguageFactory | $langFactory, | ||
LocalisationCache | $localisationCache, | ||
LanguageNameUtils | $languageNameUtils, | ||
LanguageFallback | $languageFallback, | ||
HookContainer | $hookContainer, | ||
ParserFactory | $parserFactory ) |
WANObjectCache | $wanCache | |
BagOStuff | $clusterCache | |
BagOStuff | $serverCache | |
Language | $contLang | Content language of site |
LanguageConverterFactory | $langConverterFactory | |
LoggerInterface | $logger | |
ServiceOptions | $options | |
LanguageFactory | $langFactory | |
LocalisationCache | $localisationCache | |
LanguageNameUtils | $languageNameUtils | |
LanguageFallback | $languageFallback | |
HookContainer | $hookContainer | |
ParserFactory | $parserFactory |
Definition at line 225 of file MessageCache.php.
References MediaWiki\Config\ServiceOptions\assertRequiredOptions(), disable(), MediaWiki\Config\ServiceOptions\get(), MediaWiki\Language\Language\getCode(), and MediaWiki\Languages\LanguageConverterFactory\getLanguageConverter().
MessageCache::clear | ( | ) |
Clear all stored messages in global and local cache.
Mainly used after a mass rebuild
Definition at line 1625 of file MessageCache.php.
MessageCache::disable | ( | ) |
Definition at line 1596 of file MessageCache.php.
Referenced by __construct(), get(), and replace().
MessageCache::enable | ( | ) |
Definition at line 1600 of file MessageCache.php.
MessageCache::figureMessage | ( | $key | ) |
string | $key |
Definition at line 1637 of file MessageCache.php.
Referenced by replace().
MessageCache::get | ( | $key, | |
$useDB = true, | |||
$language = null, | |||
& | $usedKey = '' ) |
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):
This process provides a number of guarantees. When changing this code, make sure all of these guarantees are preserved.
string | $key | The message key |
bool | $useDB | If true, look for the message in the DB, false to use only the compiled l10n cache. |
bool | string | Language | null | $language | Code of the language to get the message for.
|
string | &$usedKey | that the message was fetched from (the requested key may be overridden by hooks). |
Definition at line 1065 of file MessageCache.php.
References disable().
MessageCache::getAllMessageKeys | ( | $code | ) |
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.
string | $code | Language code |
Definition at line 1666 of file MessageCache.php.
MessageCache::getCheckKey | ( | $code | ) |
string | $code | Language code |
Definition at line 1707 of file MessageCache.php.
Referenced by refreshAndReplaceInternal().
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.
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.
string | $title | Message cache key with the initial uppercase letter |
string | $code | Code denoting the language to try |
Definition at line 1331 of file MessageCache.php.
MessageCache::isDisabled | ( | ) |
Whether DB/cache usage is disabled for determining messages.
If so, this typically indicates either:
Definition at line 1616 of file MessageCache.php.
|
static |
Normalize message key input.
string | $key | Input message key to be normalized |
Definition at line 193 of file MessageCache.php.
MessageCache::parse | ( | $text, | |
?PageReference | $page = null, | ||
$linestart = true, | |||
$interface = false, | |||
$language = null ) |
string | $text | |
PageReference | null | $page | |
bool | $linestart | Whether this is at the start of a line |
bool | $interface | Whether this is an interface message |
Language | StubUserLang | string | null | $language | Language code |
Definition at line 1552 of file MessageCache.php.
References $wgTitle, and NS_SPECIAL.
MessageCache::parseWithPostprocessing | ( | string | $text, |
PageReference | $contextPage, | ||
bool | $linestart = true, | ||
bool | $interface = false, | ||
$language = null ) |
string | $text | |
PageReference | $contextPage | |
bool | $linestart | Whether this should be parsed in start-of-line context (defaults to true) |
bool | $interface | Whether this is an interface message (defaults to false) |
Language | StubUserLang | string | null | $language | Language code |
Definition at line 1518 of file MessageCache.php.
MessageCache::refreshAndReplaceInternal | ( | string | $code, |
array | $replacements ) |
string | $code | |
array[] | $replacements | List of (title, message key) pairs |
Definition at line 836 of file MessageCache.php.
References MapCacheLRU\get(), getCheckKey(), and NS_MEDIAWIKI.
MessageCache::replace | ( | $title, | |
$text ) |
Updates cache as necessary when message page is changed.
string | $title | Message cache key with the initial uppercase letter |
string | false | $text | New contents of the page (false if deleted) |
Definition at line 805 of file MessageCache.php.
References disable(), and figureMessage().
MessageCache::setLogger | ( | LoggerInterface | $logger | ) |
Definition at line 265 of file MessageCache.php.
MessageCache::transform | ( | $message, | |
$interface = false, | |||
$language = null, | |||
?PageReference | $page = null ) |
string | $message | |
bool | $interface | |
Language | null | $language | |
PageReference | null | $page |
Definition at line 1465 of file MessageCache.php.
MessageCache::updateMessageOverride | ( | $page, | |
?Content | $content = null ) |
Purge message caches when a MediaWiki: page is created, updated, or deleted.
PageIdentity | $page | Message page |
Content | null | $content | New content for edit/create, null on deletion |
Definition at line 1692 of file MessageCache.php.
const MessageCache::CONSTRUCTOR_OPTIONS |
Options to be included in the ServiceOptions.
Definition at line 76 of file MessageCache.php.
const MessageCache::MAX_REQUEST_LANGUAGES = 10 |
The size of the MapCacheLRU which stores message data.
The maximum number of languages which can be efficiently loaded in a given request.
Definition at line 88 of file MessageCache.php.