More documentation updates
This commit is contained in:
parent
1ba364df99
commit
450814de00
7 changed files with 111 additions and 10 deletions
|
|
@ -35,6 +35,8 @@ class DeferredUpdates {
|
|||
* HTMLCacheUpdates are the most common deferred update people use. This
|
||||
* is a shortcut method for that.
|
||||
* @see HTMLCacheUpdate::__construct()
|
||||
* @param $title
|
||||
* @param $table
|
||||
*/
|
||||
public static function addHTMLCacheUpdate( $title, $table ) {
|
||||
self::addUpdate( new HTMLCacheUpdate( $title, $table ) );
|
||||
|
|
|
|||
|
|
@ -40,6 +40,8 @@ class LocalisationCache {
|
|||
|
||||
/**
|
||||
* The persistent store object. An instance of LCStore.
|
||||
*
|
||||
* @var LCStore
|
||||
*/
|
||||
var $store;
|
||||
|
||||
|
|
@ -132,6 +134,8 @@ class LocalisationCache {
|
|||
*/
|
||||
static public $preloadedKeys = array( 'dateFormats', 'namespaceNames' );
|
||||
|
||||
var $mergeableKeys = array();
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
* For constructor parameters, see the documentation in DefaultSettings.php
|
||||
|
|
@ -180,6 +184,8 @@ class LocalisationCache {
|
|||
/**
|
||||
* 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 ) ) {
|
||||
|
|
@ -199,6 +205,9 @@ class LocalisationCache {
|
|||
*
|
||||
* 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] ) ) {
|
||||
|
|
@ -216,6 +225,10 @@ class LocalisationCache {
|
|||
|
||||
/**
|
||||
* 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] )
|
||||
|
|
@ -241,6 +254,9 @@ class LocalisationCache {
|
|||
*
|
||||
* 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 ) ) {
|
||||
|
|
@ -257,6 +273,8 @@ class LocalisationCache {
|
|||
|
||||
/**
|
||||
* Load an item into the cache.
|
||||
* @param $code
|
||||
* @param $key
|
||||
*/
|
||||
protected function loadItem( $code, $key ) {
|
||||
if ( !isset( $this->initialisedLangs[$code] ) ) {
|
||||
|
|
@ -290,6 +308,10 @@ class LocalisationCache {
|
|||
|
||||
/**
|
||||
* 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 ) ) {
|
||||
|
|
@ -350,6 +372,7 @@ class LocalisationCache {
|
|||
|
||||
/**
|
||||
* Initialise a language in this object. Rebuild the cache if necessary.
|
||||
* @param $code
|
||||
*/
|
||||
protected function initLanguage( $code ) {
|
||||
if ( isset( $this->initialisedLangs[$code] ) ) {
|
||||
|
|
@ -406,6 +429,8 @@ class LocalisationCache {
|
|||
/**
|
||||
* 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];
|
||||
|
|
@ -416,6 +441,9 @@ class LocalisationCache {
|
|||
|
||||
/**
|
||||
* Read a PHP file containing localisation data.
|
||||
* @param $_fileName
|
||||
* @param $_fileType
|
||||
* @return array
|
||||
*/
|
||||
protected function readPHPFile( $_fileName, $_fileType ) {
|
||||
// Disable APC caching
|
||||
|
|
@ -437,6 +465,9 @@ class LocalisationCache {
|
|||
/**
|
||||
* 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 ) ) {
|
||||
|
|
@ -464,6 +495,10 @@ class LocalisationCache {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $value
|
||||
* @param $fallbackValue
|
||||
*/
|
||||
protected function mergeMagicWords( &$value, $fallbackValue ) {
|
||||
foreach ( $fallbackValue as $magicName => $fallbackInfo ) {
|
||||
if ( !isset( $value[$magicName] ) ) {
|
||||
|
|
@ -485,6 +520,11 @@ class LocalisationCache {
|
|||
*
|
||||
* 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;
|
||||
|
|
@ -501,6 +541,7 @@ class LocalisationCache {
|
|||
/**
|
||||
* 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;
|
||||
|
|
@ -688,6 +729,8 @@ class LocalisationCache {
|
|||
*
|
||||
* 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() );
|
||||
|
|
@ -710,6 +753,7 @@ class LocalisationCache {
|
|||
/**
|
||||
* Unload the data for a given language from the object cache.
|
||||
* Reduces memory usage.
|
||||
* @param $code
|
||||
*/
|
||||
public function unload( $code ) {
|
||||
unset( $this->data[$code] );
|
||||
|
|
@ -781,6 +825,8 @@ interface LCStore {
|
|||
/**
|
||||
* 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 );
|
||||
}
|
||||
|
|
@ -792,7 +838,12 @@ interface LCStore {
|
|||
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 ) {
|
||||
|
|
@ -999,6 +1050,11 @@ class LocalisationCache_BulkLoad extends LocalisationCache {
|
|||
*/
|
||||
var $maxLoadedLangs = 10;
|
||||
|
||||
/**
|
||||
* @param $fileName
|
||||
* @param $fileType
|
||||
* @return array|mixed
|
||||
*/
|
||||
protected function readPHPFile( $fileName, $fileType ) {
|
||||
$serialize = $fileType === 'core';
|
||||
if ( !isset( $this->fileCache[$fileName][$fileType] ) ) {
|
||||
|
|
@ -1020,18 +1076,32 @@ class LocalisationCache_BulkLoad extends LocalisationCache {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @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] );
|
||||
|
|
@ -1039,6 +1109,9 @@ class LocalisationCache_BulkLoad extends LocalisationCache {
|
|||
$this->trimCache();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $code
|
||||
*/
|
||||
public function unload( $code ) {
|
||||
unset( $this->mruLangs[$code] );
|
||||
parent::unload( $code );
|
||||
|
|
|
|||
|
|
@ -726,7 +726,7 @@ class LogEventsList {
|
|||
/**
|
||||
* SQL clause to skip forbidden log types for this user
|
||||
*
|
||||
* @param $db Database
|
||||
* @param $db DatabaseBase
|
||||
* @param $audience string, public/user
|
||||
* @return Mixed: string or false
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -1259,15 +1259,26 @@ class FauxRequest extends WebRequest {
|
|||
$this->headers[$name] = $val;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $key
|
||||
* @return mixed
|
||||
*/
|
||||
public function getSessionData( $key ) {
|
||||
if( isset( $this->session[$key] ) )
|
||||
return $this->session[$key];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $key
|
||||
* @param $data
|
||||
*/
|
||||
public function setSessionData( $key, $data ) {
|
||||
$this->session[$key] = $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array|Mixed|null
|
||||
*/
|
||||
public function getSessionArray() {
|
||||
return $this->session;
|
||||
}
|
||||
|
|
|
|||
11
includes/cache/HTMLCacheUpdate.php
vendored
11
includes/cache/HTMLCacheUpdate.php
vendored
|
|
@ -32,6 +32,12 @@ class HTMLCacheUpdate implements DeferrableUpdate {
|
|||
public $mTable, $mPrefix, $mStart, $mEnd;
|
||||
public $mRowsPerJob, $mRowsPerQuery;
|
||||
|
||||
/**
|
||||
* @param $titleTo
|
||||
* @param $table
|
||||
* @param $start bool
|
||||
* @param $end bool
|
||||
*/
|
||||
function __construct( $titleTo, $table, $start = false, $end = false ) {
|
||||
global $wgUpdateRowsPerJob, $wgUpdateRowsPerQuery;
|
||||
|
||||
|
|
@ -50,7 +56,6 @@ class HTMLCacheUpdate implements DeferrableUpdate {
|
|||
return;
|
||||
}
|
||||
|
||||
|
||||
# Get an estimate of the number of rows from the BacklinkCache
|
||||
$numRows = $this->mCache->getNumLinks( $this->mTable );
|
||||
if ( $numRows > $this->mRowsPerJob * 2 ) {
|
||||
|
|
@ -138,6 +143,9 @@ class HTMLCacheUpdate implements DeferrableUpdate {
|
|||
Job::batchInsert( $jobs );
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
protected function insertJobs() {
|
||||
$batches = $this->mCache->partition( $this->mTable, $this->mRowsPerJob );
|
||||
if ( !$batches ) {
|
||||
|
|
@ -157,6 +165,7 @@ class HTMLCacheUpdate implements DeferrableUpdate {
|
|||
|
||||
/**
|
||||
* Invalidate an array (or iterator) of Title objects, right now
|
||||
* @param $titleArray array
|
||||
*/
|
||||
protected function invalidateTitles( $titleArray ) {
|
||||
global $wgUseFileCache, $wgUseSquid;
|
||||
|
|
|
|||
|
|
@ -35,9 +35,9 @@ abstract class ContextSource implements IContextSource {
|
|||
private $context;
|
||||
|
||||
/**
|
||||
* Get the IContextSource object
|
||||
* Get the RequestContext object
|
||||
*
|
||||
* @return IContextSource
|
||||
* @return RequestContext
|
||||
*/
|
||||
public function getContext() {
|
||||
if ( $this->context === null ) {
|
||||
|
|
|
|||
|
|
@ -117,6 +117,10 @@ TEXT;
|
|||
$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();
|
||||
|
|
@ -135,6 +139,10 @@ TEXT;
|
|||
$this->pageCount++;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $rev Revision
|
||||
* @return mixed
|
||||
*/
|
||||
function handleRevision( $rev ) {
|
||||
$title = $rev->getTitle();
|
||||
if ( !$title ) {
|
||||
|
|
@ -161,7 +169,7 @@ TEXT;
|
|||
function handleUpload( $revision ) {
|
||||
if ( $this->uploads ) {
|
||||
if ( $this->skippedNamespace( $revision ) ) {
|
||||
return ;
|
||||
return;
|
||||
}
|
||||
$this->uploadCount++;
|
||||
// $this->report();
|
||||
|
|
@ -223,11 +231,9 @@ TEXT;
|
|||
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;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue