[ Index ]

PHP Cross Reference of MediaWiki-1.24.0

title

Body

[close]

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

Cache of the contents of localisation files. 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: 1460 lines (41 kb)
Included or required:0 times
Referenced: 6 times
Includes or requires: 0 files

Defines 6 classes

LocalisationCache:: (26 methods):
  __construct()
  isMergeableKey()
  getItem()
  getSubitem()
  getSubitemList()
  loadItem()
  loadSubitem()
  isExpired()
  initLanguage()
  initShallowFallback()
  readPHPFile()
  readJSONFile()
  getCompiledPluralRules()
  getPluralRules()
  getPluralRuleTypes()
  loadPluralFiles()
  loadPluralFile()
  readSourceFilesAndRegisterDeps()
  mergeItem()
  mergeMagicWords()
  mergeExtensionItem()
  recache()
  buildPreload()
  unload()
  unloadAll()
  disableBackend()

LCStore:: (4 methods):
  get()
  startWrite()
  finishWrite()
  set()

LCStoreDB:: (4 methods):
  get()
  startWrite()
  finishWrite()
  set()

LCStoreCDB:: (6 methods):
  __construct()
  get()
  startWrite()
  finishWrite()
  set()
  getFileName()

LCStoreNull:: (4 methods):
  get()
  startWrite()
  finishWrite()
  set()

LocalisationCacheBulkLoad:: (6 methods):
  readPHPFile()
  getItem()
  getSubitem()
  recache()
  unload()
  trimCache()


Class: LocalisationCache  - X-Ref

Class for caching the contents of localisation files, Messages*.php
and *.i18n.php.

An instance of this class is available using Language::getLocalisationCache().

The values retrieved from here are merged, containing items from extension
files, core messages files and the language fallback sequence (e.g. zh-cn ->
zh-hans -> en ). Some common errors are corrected, for example namespace
names with spaces instead of underscores, but heavyweight processing, such
as grammatical transformation, is done by the caller.
__construct( $conf )   X-Ref
Constructor.
For constructor parameters, see the documentation in DefaultSettings.php
for $wgLocalisationCacheConf.

param: array $conf

isMergeableKey( $key )   X-Ref
Returns true if the given key is mergeable, that is, if it is an associative
array which can be merged through a fallback sequence.

param: string $key
return: bool

getItem( $code, $key )   X-Ref
Get a cache item.

Warning: this may be slow for split items (messages), since it will
need to fetch all of the subitems from the cache individually.
param: string $code
param: string $key
return: mixed

getSubitem( $code, $key, $subkey )   X-Ref
Get a subitem, for instance a single message for a given language.

param: string $code
param: string $key
param: string $subkey
return: mixed|null

getSubitemList( $code, $key )   X-Ref
Get the list of subitem keys for a given item.

This is faster than array_keys($lc->getItem(...)) for the items listed in
self::$splitKeys.

Will return null if the item is not found, or false if the item is not an
array.
param: string $code
param: string $key
return: bool|null|string

loadItem( $code, $key )   X-Ref
Load an item into the cache.

param: string $code
param: string $key

loadSubitem( $code, $key, $subkey )   X-Ref
Load a subitem into the cache

param: string $code
param: string $key
param: string $subkey

isExpired( $code )   X-Ref
Returns true if the cache identified by $code is missing or expired.

param: string $code
return: bool

initLanguage( $code )   X-Ref
Initialise a language in this object. Rebuild the cache if necessary.

param: string $code

initShallowFallback( $primaryCode, $fallbackCode )   X-Ref
Create a fallback from one language to another, without creating a
complete persistent cache.

param: string $primaryCode
param: string $fallbackCode

readPHPFile( $_fileName, $_fileType )   X-Ref
Read a PHP file containing localisation data.

param: string $_fileName
param: string $_fileType
return: array

readJSONFile( $fileName )   X-Ref
Read a JSON file containing localisation messages.

param: string $fileName Name of file to read
return: array Array with a 'messages' key, or empty array if the file doesn't exist

getCompiledPluralRules( $code )   X-Ref
Get the compiled plural rules for a given language from the XML files.

param: string $code
return: array|null

getPluralRules( $code )   X-Ref
Get the plural rules for a given language from the XML files.
Cached.

param: string $code
return: array|null

getPluralRuleTypes( $code )   X-Ref
Get the plural rule types for a given language from the XML files.
Cached.

param: string $code
return: array|null

loadPluralFiles()   X-Ref
Load the plural XML files.


loadPluralFile( $fileName )   X-Ref
Load a plural XML file with the given filename, compile the relevant
rules, and save the compiled rules in a process-local cache.

param: string $fileName

readSourceFilesAndRegisterDeps( $code, &$deps )   X-Ref
Read the data from the source files for a given language, and register
the relevant dependencies in the $deps array. If the localisation
exists, the data array is returned, otherwise false is returned.

param: string $code
param: array $deps
return: array

mergeItem( $key, &$value, $fallbackValue )   X-Ref
Merge two localisation values, a primary and a fallback, overwriting the
primary value in place.

param: string $key
param: mixed $value
param: mixed $fallbackValue

mergeMagicWords( &$value, $fallbackValue )   X-Ref

param: mixed $value
param: mixed $fallbackValue

mergeExtensionItem( $codeSequence, $key, &$value, $fallbackValue )   X-Ref
Given an array mapping language code to localisation value, such as is
found in extension *.i18n.php files, iterate through a fallback sequence
to merge the given data with an existing primary value.

Returns true if any data from the extension array was used, false
otherwise.
param: array $codeSequence
param: string $key
param: mixed $value
param: mixed $fallbackValue
return: bool

recache( $code )   X-Ref
Load localisation data for a given language for both core and extensions
and save it to the persistent cache store and the process cache

param: string $code

buildPreload( $data )   X-Ref
Build the preload item from the given pre-cache data.

The preload item will be loaded automatically, improving performance
for the commonly-requested items it contains.
param: array $data
return: array

unload( $code )   X-Ref
Unload the data for a given language from the object cache.
Reduces memory usage.

param: string $code

unloadAll()   X-Ref
Unload all data


disableBackend()   X-Ref
Disable the storage backend


Interface: LCStore  - X-Ref

Interface for the persistence layer of LocalisationCache.

The persistence layer is two-level hierarchical cache. The first level
is the language, the second level is the item or subitem.

Since the data for a whole language is rebuilt in one operation, it needs
to have a fast and atomic method for deleting or replacing all of the
current data for a given language. The interface reflects this bulk update
operation. Callers writing to the cache must first call startWrite(), then
will call set() a couple of thousand times, then will call finishWrite()
to commit the operation. When finishWrite() is called, the cache is
expected to delete all data previously stored for that language.

The values stored are PHP variables suitable for serialize(). Implementations
of LCStore are responsible for serializing and unserializing.
get( $code, $key )   X-Ref
Get a value.

param: string $code Language code
param: string $key Cache key

startWrite( $code )   X-Ref
Start a write transaction.

param: string $code Language code

finishWrite()   X-Ref
Finish a write transaction.


set( $key, $value )   X-Ref
Set a key to a given value. startWrite() must be called before this
is called, and finishWrite() must be called afterwards.

param: string $key
param: mixed $value

Class: LCStoreDB  - X-Ref

LCStore implementation which uses the standard DB functions to store data.
This will work on any MediaWiki installation.

get( $code, $key )   X-Ref
No description

startWrite( $code )   X-Ref
No description

finishWrite()   X-Ref
No description

set( $key, $value )   X-Ref
No description

Class: LCStoreCDB  - X-Ref

LCStore implementation which stores data as a collection of CDB files in the
directory given by $wgCacheDirectory. If $wgCacheDirectory is not set, this
will throw an exception.

Profiling indicates that on Linux, this implementation outperforms MySQL if
the directory is on a local filesystem and there is ample kernel cache
space. The performance advantage is greater when the DBA extension is
available than it is with the PHP port.

See Cdb.php and http://cr.yp.to/cdb.html
__construct( $conf = array()   X-Ref
No description

get( $code, $key )   X-Ref
No description

startWrite( $code )   X-Ref
No description

finishWrite()   X-Ref
No description

set( $key, $value )   X-Ref
No description

getFileName( $code )   X-Ref
No description

Class: LCStoreNull  - X-Ref

Null store backend, used to avoid DB errors during install

get( $code, $key )   X-Ref
No description

startWrite( $code )   X-Ref
No description

finishWrite()   X-Ref
No description

set( $key, $value )   X-Ref
No description

Class: LocalisationCacheBulkLoad  - X-Ref

A localisation cache optimised for loading large amounts of data for many
languages. Used by rebuildLocalisationCache.php.

readPHPFile( $fileName, $fileType )   X-Ref

param: string $fileName
param: string $fileType
return: array|mixed

getItem( $code, $key )   X-Ref

param: string $code
param: string $key
return: mixed

getSubitem( $code, $key, $subkey )   X-Ref

param: string $code
param: string $key
param: string $subkey
return: mixed

recache( $code )   X-Ref

param: string $code

unload( $code )   X-Ref

param: string $code

trimCache()   X-Ref
Unload cached languages until there are less than $this->maxLoadedLangs




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