/**
* The persistent store object. An instance of LCStore.
+ *
+ * @var LCStore
*/
var $store;
*/
static public $preloadedKeys = array( 'dateFormats', 'namespaceNames' );
+ var $mergeableKeys = array();
+
/**
* Constructor.
* For constructor parameters, see the documentation in DefaultSettings.php
/**
* 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 $key
+ * @return bool
*/
public function isMergeableKey( $key ) {
if ( !isset( $this->mergeableKeys ) ) {
*
* Warning: this may be slow for split items (messages), since it will
* need to fetch all of the subitems from the cache individually.
+ * @param $code
+ * @param $key
+ * @return string
*/
public function getItem( $code, $key ) {
if ( !isset( $this->loadedItems[$code][$key] ) ) {
/**
* Get a subitem, for instance a single message for a given language.
+ * @param $code
+ * @param $key
+ * @param $subkey
+ * @return null
*/
public function getSubitem( $code, $key, $subkey ) {
if ( !isset( $this->loadedSubitems[$code][$key][$subkey] )
*
* Will return null if the item is not found, or false if the item is not an
* array.
+ * @param $code
+ * @param $key
+ * @return bool|null|string
*/
public function getSubitemList( $code, $key ) {
if ( in_array( $key, self::$splitKeys ) ) {
/**
* Load an item into the cache.
+ * @param $code
+ * @param $key
*/
protected function loadItem( $code, $key ) {
if ( !isset( $this->initialisedLangs[$code] ) ) {
/**
* Load a subitem into the cache
+ * @param $code
+ * @param $key
+ * @param $subkey
+ * @return
*/
protected function loadSubitem( $code, $key, $subkey ) {
if ( !in_array( $key, self::$splitKeys ) ) {
/**
* Initialise a language in this object. Rebuild the cache if necessary.
+ * @param $code
*/
protected function initLanguage( $code ) {
if ( isset( $this->initialisedLangs[$code] ) ) {
/**
* Create a fallback from one language to another, without creating a
* complete persistent cache.
+ * @param $primaryCode
+ * @param $fallbackCode
*/
public function initShallowFallback( $primaryCode, $fallbackCode ) {
$this->data[$primaryCode] =& $this->data[$fallbackCode];
/**
* Read a PHP file containing localisation data.
+ * @param $_fileName
+ * @param $_fileType
+ * @return array
*/
protected function readPHPFile( $_fileName, $_fileType ) {
// Disable APC caching
/**
* Merge two localisation values, a primary and a fallback, overwriting the
* primary value in place.
+ * @param $key
+ * @param $value
+ * @param $fallbackValue
*/
protected function mergeItem( $key, &$value, $fallbackValue ) {
if ( !is_null( $value ) ) {
}
}
+ /**
+ * @param $value
+ * @param $fallbackValue
+ */
protected function mergeMagicWords( &$value, $fallbackValue ) {
foreach ( $fallbackValue as $magicName => $fallbackInfo ) {
if ( !isset( $value[$magicName] ) ) {
*
* Returns true if any data from the extension array was used, false
* otherwise.
+ * @param $codeSequence
+ * @param $key
+ * @param $value
+ * @param $fallbackValue
+ * @return bool
*/
protected function mergeExtensionItem( $codeSequence, $key, &$value, $fallbackValue ) {
$used = false;
/**
* 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 $code
*/
public function recache( $code ) {
global $wgExtensionMessagesFiles, $wgExtensionAliasesFiles;
*
* The preload item will be loaded automatically, improving performance
* for the commonly-requested items it contains.
+ * @param $data
+ * @return array
*/
protected function buildPreload( $data ) {
$preload = array( 'messages' => array() );
/**
* Unload the data for a given language from the object cache.
* Reduces memory usage.
+ * @param $code
*/
public function unload( $code ) {
unset( $this->data[$code] );
/**
* Set a key to a given value. startWrite() must be called before this
* is called, and finishWrite() must be called afterwards.
+ * @param $key
+ * @param $value
*/
function set( $key, $value );
}
class LCStore_DB implements LCStore {
var $currentLang;
var $writesDone = false;
- var $dbw, $batch;
+
+ /**
+ * @var DatabaseBase
+ */
+ var $dbw;
+ var $batch;
var $readOnly = false;
public function get( $code, $key ) {
*/
var $maxLoadedLangs = 10;
+ /**
+ * @param $fileName
+ * @param $fileType
+ * @return array|mixed
+ */
protected function readPHPFile( $fileName, $fileType ) {
$serialize = $fileType === 'core';
if ( !isset( $this->fileCache[$fileName][$fileType] ) ) {
}
}
+ /**
+ * @param $code
+ * @param $key
+ * @return string
+ */
public function getItem( $code, $key ) {
unset( $this->mruLangs[$code] );
$this->mruLangs[$code] = true;
return parent::getItem( $code, $key );
}
+ /**
+ * @param $code
+ * @param $key
+ * @param $subkey
+ * @return
+ */
public function getSubitem( $code, $key, $subkey ) {
unset( $this->mruLangs[$code] );
$this->mruLangs[$code] = true;
return parent::getSubitem( $code, $key, $subkey );
}
+ /**
+ * @param $code
+ */
public function recache( $code ) {
parent::recache( $code );
unset( $this->mruLangs[$code] );
$this->trimCache();
}
+ /**
+ * @param $code
+ */
public function unload( $code ) {
unset( $this->mruLangs[$code] );
parent::unload( $code );
$this->error( "Unknown namespace text / index specified: $namespace", true );
}
+ /**
+ * @param $obj Title|Revision
+ * @return bool
+ */
private function skippedNamespace( $obj ) {
if ( $obj instanceof Title ) {
$ns = $obj->getNamespace();
$this->pageCount++;
}
+ /**
+ * @param $rev Revision
+ * @return mixed
+ */
function handleRevision( $rev ) {
$title = $rev->getTitle();
if ( !$title ) {
function handleUpload( $revision ) {
if ( $this->uploads ) {
if ( $this->skippedNamespace( $revision ) ) {
- return ;
+ return;
}
$this->uploadCount++;
// $this->report();
function importFromFile( $filename ) {
if ( preg_match( '/\.gz$/', $filename ) ) {
$filename = 'compress.zlib://' . $filename;
- }
- elseif ( preg_match( '/\.bz2$/', $filename ) ) {
+ } elseif ( preg_match( '/\.bz2$/', $filename ) ) {
$filename = 'compress.bzip2://' . $filename;
- }
- elseif ( preg_match( '/\.7z$/', $filename ) ) {
+ } elseif ( preg_match( '/\.7z$/', $filename ) ) {
$filename = 'mediawiki.compress.7z://' . $filename;
}