23use Psr\Log\LoggerAwareInterface;
24use Psr\Log\LoggerInterface;
25use Psr\Log\NullLogger;
181 $this->
cache = $params[
'cache'];
182 $this->purgeChannel = isset(
$params[
'channels'][
'purge'] )
184 : self::DEFAULT_PURGE_CHANNEL;
185 $this->purgeRelayer = isset(
$params[
'relayers'][
'purge'] )
192 $this->logger = $logger;
248 final public function get( $key, &$curTTL =
null,
array $checkKeys = [], &$asOf = null ) {
251 $values = $this->
getMulti( [ $key ], $curTTLs, $checkKeys, $asOfs );
252 $curTTL = isset( $curTTLs[$key] ) ? $curTTLs[$key] :
null;
253 $asOf = isset( $asOfs[$key] ) ? $asOfs[$key] :
null;
255 return isset( $values[$key] ) ? $values[$key] :
false;
277 $vPrefixLen = strlen( self::VALUE_KEY_PREFIX );
278 $valueKeys = self::prefixCacheKeys(
$keys, self::VALUE_KEY_PREFIX );
280 $checkKeysForAll = [];
281 $checkKeysByKey = [];
283 foreach ( $checkKeys
as $i => $checkKeyGroup ) {
284 $prefixed = self::prefixCacheKeys( (
array)$checkKeyGroup, self::TIME_KEY_PREFIX );
285 $checkKeysFlat = array_merge( $checkKeysFlat, $prefixed );
287 if ( is_int( $i ) ) {
288 $checkKeysForAll = array_merge( $checkKeysForAll, $prefixed );
290 $checkKeysByKey[$i] = isset( $checkKeysByKey[$i] )
291 ? array_merge( $checkKeysByKey[$i], $prefixed )
297 $keysGet = array_merge( $valueKeys, $checkKeysFlat );
298 if ( $this->warmupCache ) {
299 $wrappedValues = array_intersect_key( $this->warmupCache, array_flip( $keysGet ) );
300 $keysGet = array_diff( $keysGet, array_keys( $wrappedValues ) );
304 $wrappedValues += $this->
cache->getMulti( $keysGet );
306 $now = microtime(
true );
309 $purgeValuesForAll = $this->
processCheckKeys( $checkKeysForAll, $wrappedValues, $now );
310 $purgeValuesByKey = [];
311 foreach ( $checkKeysByKey
as $cacheKey => $checks ) {
312 $purgeValuesByKey[$cacheKey] =
317 foreach ( $valueKeys
as $vKey ) {
318 if ( !isset( $wrappedValues[$vKey] ) ) {
322 $key = substr( $vKey, $vPrefixLen );
330 $purgeValues = $purgeValuesForAll;
331 if ( isset( $purgeValuesByKey[$key] ) ) {
332 $purgeValues = array_merge( $purgeValues, $purgeValuesByKey[$key] );
334 foreach ( $purgeValues
as $purge ) {
335 $safeTimestamp = $purge[self::FLD_TIME] + $purge[self::FLD_HOLDOFF];
336 if ( $safeTimestamp >= $wrappedValues[$vKey][self::FLD_TIME] ) {
338 $ago = min( $purge[self::FLD_TIME] - $now, self::TINY_NEGATIVE );
340 $curTTL = min( $curTTL, $ago );
344 $curTTLs[$key] = $curTTL;
345 $asOfs[$key] = (
$value !==
false ) ? $wrappedValues[$vKey][self::FLD_TIME] :
null;
360 foreach ( $timeKeys
as $timeKey ) {
361 $purge = isset( $wrappedValues[$timeKey] )
362 ? self::parsePurgeValue( $wrappedValues[$timeKey] )
364 if ( $purge ===
false ) {
367 $this->
cache->add( $timeKey, $newVal, self::CHECK_KEY_TTL );
368 $purge = self::parsePurgeValue( $newVal );
370 $purgeValues[] = $purge;
433 final public function set( $key,
$value, $ttl = 0,
array $opts = [] ) {
434 $now = microtime(
true );
435 $lockTSE = isset( $opts[
'lockTSE'] ) ? $opts[
'lockTSE'] : self::TSE_NONE;
436 $age = isset( $opts[
'since'] ) ? max( 0, $now - $opts[
'since'] ) : 0;
437 $lag = isset( $opts[
'lag'] ) ? $opts[
'lag'] : 0;
438 $staleTTL = isset( $opts[
'staleTTL'] ) ? $opts[
'staleTTL'] : 0;
441 if ( !empty( $opts[
'pending'] ) ) {
442 $this->logger->info(
"Rejected set() for $key due to pending writes." );
449 if ( $lag ===
false || ( $lag + $age ) > self::MAX_READ_LAG ) {
451 if ( $lockTSE >= 0 ) {
452 $ttl = max( 1, (
int)$lockTSE );
453 $wrapExtra[self::FLD_FLAGS] = self::FLG_STALE;
455 } elseif ( $age > self::MAX_READ_LAG ) {
456 $this->logger->info(
"Rejected set() for $key due to snapshot lag." );
460 } elseif ( $lag ===
false || $lag > self::MAX_READ_LAG ) {
461 $ttl = $ttl ? min( $ttl, self::TTL_LAGGED ) : self::TTL_LAGGED;
462 $this->logger->warning(
"Lowered set() TTL for $key due to replication lag." );
465 $this->logger->info(
"Rejected set() for $key due to high read lag." );
472 $wrapped = $this->
wrap(
$value, $ttl, $now ) + $wrapExtra;
474 $func =
function (
$cache, $key, $cWrapped )
use ( $wrapped ) {
475 return ( is_string( $cWrapped ) )
480 return $this->
cache->merge( self::VALUE_KEY_PREFIX . $key, $func, $ttl + $staleTTL, 1 );
540 final public function delete( $key, $ttl = self::HOLDOFF_TTL ) {
541 $key = self::VALUE_KEY_PREFIX . $key;
548 $ok = $this->
relayPurge( $key, $ttl, self::HOLDOFF_NONE );
574 $key = self::TIME_KEY_PREFIX . $key;
576 $purge = self::parsePurgeValue( $this->
cache->get( $key ) );
577 if ( $purge !==
false ) {
578 $time = $purge[self::FLD_TIME];
581 $now = (
string)microtime(
true );
582 $this->
cache->add( $key,
627 return $this->
relayPurge( self::TIME_KEY_PREFIX . $key, self::CHECK_KEY_TTL, $holdoff );
662 return $this->
relayDelete( self::TIME_KEY_PREFIX . $key );
855 $pcTTL = isset( $opts[
'pcTTL'] ) ? $opts[
'pcTTL'] : self::TTL_UNCACHEABLE;
860 if ( $pcTTL >= 0 && $this->callbackDepth == 0 ) {
861 $group = isset( $opts[
'pcGroup'] ) ? $opts[
'pcGroup'] : self::PC_PRIMARY;
863 $value = $procCache->get( $key );
871 if ( isset( $opts[
'version'] ) ) {
872 $version = $opts[
'version'];
877 function ( $oldValue, &$ttl, &$setOpts, $oldAsOf )
878 use ( $callback, $version ) {
879 if ( is_array( $oldValue )
880 && array_key_exists( self::VFLD_DATA, $oldValue )
882 $oldData = $oldValue[self::VFLD_DATA];
889 self::VFLD_DATA => $callback( $oldData, $ttl, $setOpts, $oldAsOf ),
890 self::VFLD_VERSION => $version
896 if ( $cur[self::VFLD_VERSION] === $version ) {
898 $value = $cur[self::VFLD_DATA];
903 'cache-variant:' . md5( $key ) .
":$version",
907 [
'version' =>
null,
'minAsOf' => $asOf ] + $opts
915 if ( $procCache &&
$value !==
false ) {
916 $procCache->set( $key,
$value, $pcTTL );
937 $lowTTL = isset( $opts[
'lowTTL'] ) ? $opts[
'lowTTL'] : min( self::LOW_TTL, $ttl );
938 $lockTSE = isset( $opts[
'lockTSE'] ) ? $opts[
'lockTSE'] : self::TSE_NONE;
939 $checkKeys = isset( $opts[
'checkKeys'] ) ? $opts[
'checkKeys'] : [];
940 $busyValue = isset( $opts[
'busyValue'] ) ? $opts[
'busyValue'] :
null;
941 $popWindow = isset( $opts[
'hotTTR'] ) ? $opts[
'hotTTR'] : self::HOT_TTR;
942 $ageNew = isset( $opts[
'ageNew'] ) ? $opts[
'ageNew'] : self::AGE_NEW;
943 $minTime = isset( $opts[
'minAsOf'] ) ? $opts[
'minAsOf'] : self::MIN_TIMESTAMP_NONE;
944 $versioned = isset( $opts[
'version'] );
948 $cValue = $this->
get( $key, $curTTL, $checkKeys, $asOf );
951 $preCallbackTime = microtime(
true );
963 $isTombstone = ( $curTTL !==
null &&
$value ===
false );
965 $isHot = ( $curTTL !==
null && $curTTL <= 0 && abs( $curTTL ) <= $lockTSE );
967 $checkBusy = ( $busyValue !==
null &&
$value ===
false );
972 $useMutex = ( $isHot || ( $isTombstone && $lockTSE > 0 ) || $checkBusy );
974 $lockAcquired =
false;
977 if ( $this->
cache->add( self::MUTEX_KEY_PREFIX . $key, 1, self::LOCK_TTL ) ) {
979 $lockAcquired =
true;
987 $wrapped = $this->
cache->get( self::INTERIM_KEY_PREFIX . $key );
990 $asOf = $wrapped[self::FLD_TIME];
995 if ( $busyValue !==
null ) {
996 return is_callable( $busyValue ) ? $busyValue() : $busyValue;
1001 if ( !is_callable( $callback ) ) {
1002 throw new InvalidArgumentException(
"Invalid cache miss callback provided." );
1007 ++$this->callbackDepth;
1009 $value = call_user_func_array( $callback, [ $cValue, &$ttl, &$setOpts, $asOf ] );
1011 --$this->callbackDepth;
1015 if ( ( $isTombstone && $lockTSE > 0 ) &&
$value !==
false && $ttl >= 0 ) {
1016 $tempTTL = max( 1, (
int)$lockTSE );
1017 $newAsOf = microtime(
true );
1018 $wrapped = $this->
wrap(
$value, $tempTTL, $newAsOf );
1020 $this->
cache->merge(
1021 self::INTERIM_KEY_PREFIX . $key,
1022 function ()
use ( $wrapped ) {
1030 if (
$value !==
false && $ttl >= 0 ) {
1031 $setOpts[
'lockTSE'] = $lockTSE;
1033 $setOpts += [
'since' => $preCallbackTime ];
1035 $this->
set( $key,
$value, $ttl, $setOpts );
1038 if ( $lockAcquired ) {
1040 $this->
cache->changeTTL( self::MUTEX_KEY_PREFIX . $key, 1 );
1104 ArrayIterator $keyedIds, $ttl, callable $callback,
array $opts = []
1106 $keysWarmUp = iterator_to_array( $keyedIds,
true );
1107 $checkKeys = isset( $opts[
'checkKeys'] ) ? $opts[
'checkKeys'] : [];
1108 foreach ( $checkKeys
as $i => $checkKeyOrKeys ) {
1109 if ( is_int( $i ) ) {
1110 $keysWarmUp[] = $checkKeyOrKeys;
1112 $keysWarmUp = array_merge( $keysWarmUp, $checkKeyOrKeys );
1116 $this->warmupCache = $this->
cache->getMulti( $keysWarmUp );
1117 $this->warmupCache += array_fill_keys( $keysWarmUp,
false );
1121 $func =
function ( $oldValue, &$ttl,
array $setOpts, $oldAsOf )
use ( $callback, &$id ) {
1122 return $callback( $id, $oldValue, $ttl, $setOpts, $oldAsOf );
1126 foreach ( $keyedIds
as $key => $id ) {
1130 $this->warmupCache = [];
1147 public function reap( $key, $purgeTimestamp, &$isStale =
false ) {
1148 $minAsOf = $purgeTimestamp + self::HOLDOFF_TTL;
1149 $wrapped = $this->
cache->get( self::VALUE_KEY_PREFIX . $key );
1150 if ( is_array( $wrapped ) && $wrapped[self::FLD_TIME] < $minAsOf ) {
1152 $this->logger->warning(
"Reaping stale value key '$key'." );
1153 $ttlReap = self::HOLDOFF_TTL;
1154 $ok = $this->
cache->changeTTL( self::VALUE_KEY_PREFIX . $key, $ttlReap );
1156 $this->logger->error(
"Could not complete reap of key '$key'." );
1178 if ( $purge && $purge[self::FLD_TIME] < $purgeTimestamp ) {
1180 $this->logger->warning(
"Reaping stale check key '$key'." );
1181 $ok = $this->
cache->changeTTL( self::TIME_KEY_PREFIX . $key, 1 );
1183 $this->logger->error(
"Could not complete reap of check key '$key'." );
1201 return call_user_func_array( [ $this->
cache, __FUNCTION__ ], func_get_args() );
1211 return call_user_func_array( [ $this->
cache, __FUNCTION__ ], func_get_args() );
1222 foreach ( $entities
as $entity ) {
1223 $map[$keyFunc( $entity, $this )] = $entity;
1226 return new ArrayIterator( $map );
1234 if ( $this->lastRelayError ) {
1240 return $this->lastRelayError;
1245 case BagOStuff::ERR_NONE:
1246 return self::ERR_NONE;
1247 case BagOStuff::ERR_NO_RESPONSE:
1248 return self::ERR_NO_RESPONSE;
1249 case BagOStuff::ERR_UNREACHABLE:
1250 return self::ERR_UNREACHABLE;
1252 return self::ERR_UNEXPECTED;
1260 $this->
cache->clearLastError();
1261 $this->lastRelayError = self::ERR_NONE;
1270 $this->processCaches = [];
1279 return $this->
cache->getQoS( $flag );
1305 public function adaptiveTTL( $mtime, $maxTTL, $minTTL = 30, $factor = .2 ) {
1306 if ( is_float( $mtime ) || ctype_digit( $mtime ) ) {
1307 $mtime = (int)$mtime;
1310 if ( !is_int( $mtime ) || $mtime <= 0 ) {
1314 $age = time() - $mtime;
1316 return (
int)min( $maxTTL, max( $minTTL, $factor * $age ) );
1332 $ok = $this->
cache->set( $key,
1337 $event = $this->
cache->modifySimpleRelayEvent( [
1340 'val' =>
'PURGED:$UNIXTIME$:' . (
int)$holdoff,
1341 'ttl' => max( $ttl, 1 ),
1345 $ok = $this->purgeRelayer->notify( $this->purgeChannel, $event );
1347 $this->lastRelayError = self::ERR_RELAY;
1363 $ok = $this->
cache->delete( $key );
1365 $event = $this->
cache->modifySimpleRelayEvent( [
1370 $ok = $this->purgeRelayer->notify( $this->purgeChannel, $event );
1372 $this->lastRelayError = self::ERR_RELAY;
1392 if ( $curTTL >= $lowTTL ) {
1394 } elseif ( $curTTL <= 0 ) {
1398 $chance = ( 1 - $curTTL / $lowTTL );
1400 return mt_rand( 1, 1e9 ) <= 1e9 * $chance;
1419 $age = $now - $asOf;
1420 $timeOld = $age - $ageNew;
1421 if ( $timeOld <= 0 ) {
1428 $refreshWindowSec = max( $timeTillRefresh - $ageNew - self::RAMPUP_TTL / 2, 1 );
1432 $chance = 1 / ( self::HIT_RATE_HIGH * $refreshWindowSec );
1435 $chance *= ( $timeOld <= self::RAMPUP_TTL ) ? $timeOld / self::RAMPUP_TTL : 1;
1437 return mt_rand( 1, 1e9 ) <= 1e9 * $chance;
1450 if ( $versioned && !isset(
$value[self::VFLD_VERSION] ) ) {
1452 } elseif ( $minTime > 0 && $asOf < $minTime ) {
1469 self::FLD_VERSION => self::VERSION,
1470 self::FLD_VALUE =>
$value,
1471 self::FLD_TTL => $ttl,
1472 self::FLD_TIME => $now
1483 protected function unwrap( $wrapped, $now ) {
1485 $purge = self::parsePurgeValue( $wrapped );
1486 if ( $purge !==
false ) {
1488 $curTTL = min( $purge[self::FLD_TIME] - $now, self::TINY_NEGATIVE );
1489 return [
false, $curTTL ];
1492 if ( !is_array( $wrapped )
1493 || !isset( $wrapped[self::FLD_VERSION] )
1494 || $wrapped[self::FLD_VERSION] !== self::VERSION
1496 return [
false, null ];
1499 $flags = isset( $wrapped[self::FLD_FLAGS] ) ? $wrapped[self::FLD_FLAGS] : 0;
1500 if ( (
$flags & self::FLG_STALE ) == self::FLG_STALE ) {
1502 $age = $now - $wrapped[self::FLD_TIME];
1503 $curTTL = min( -$age, self::TINY_NEGATIVE );
1504 } elseif ( $wrapped[self::FLD_TTL] > 0 ) {
1506 $age = $now - $wrapped[self::FLD_TIME];
1507 $curTTL = max( $wrapped[self::FLD_TTL] - $age, 0.0 );
1513 return [ $wrapped[self::FLD_VALUE], $curTTL ];
1524 $res[] = $prefix . $key;
1536 if ( !is_string(
$value ) ) {
1539 $segments = explode(
':',
$value, 3 );
1540 if ( !isset( $segments[0] ) || !isset( $segments[1] )
1541 ||
"{$segments[0]}:" !== self::PURGE_VAL_PREFIX
1545 if ( !isset( $segments[2] ) ) {
1547 $segments[2] = self::HOLDOFF_TTL;
1550 self::FLD_TIME => (float)$segments[1],
1551 self::FLD_HOLDOFF => (
int)$segments[2],
1561 return self::PURGE_VAL_PREFIX . (float)$timestamp .
':' . (
int)$holdoff;
1569 if ( !isset( $this->processCaches[$group] ) ) {
1570 list( , $n ) = explode(
':', $group );
1571 $this->processCaches[$group] =
new HashBagOStuff( [
'maxKeys' => (
int)$n ] );
1574 return $this->processCaches[$group];
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
interface is intended to be more or less compatible with the PHP memcached client.
A BagOStuff object with no objects in it.
No-op class for publishing messages into a PubSub system.
Base class for reliable event relays.
Simple store for keeping values in an associative array for the current process.
Multi-datacenter aware caching interface.
const TINY_NEGATIVE
Tiny negative float to use when CTL comes up >= 0 due to clock skew.
const HOLDOFF_TTL
Seconds to tombstone keys on delete()
const HOT_TTR
The time length of the "popularity" refresh window for hot keys.
__construct(array $params)
unwrap( $wrapped, $now)
Do not use this method outside WANObjectCache.
worthRefreshPopular( $asOf, $ageNew, $timeTillRefresh, $now)
Check if a key is due for randomized regeneration due to its popularity.
adaptiveTTL( $mtime, $maxTTL, $minTTL=30, $factor=.2)
Get a TTL that is higher for objects that have not changed recently.
touchCheckKey( $key, $holdoff=self::HOLDOFF_TTL)
Purge a "check" key from all datacenters, invalidating keys that use it.
const LOCK_TSE
Default time-since-expiry on a miss that makes a key "hot".
mixed[] $warmupCache
Temporary warm-up cache.
const VERSION
Cache format version number.
const TTL_UNCACHEABLE
Idiom for getWithSetCallback() callbacks to avoid calling set()
const LOW_TTL
Default remaining TTL at which to consider pre-emptive regeneration.
relayPurge( $key, $ttl, $holdoff)
Do the actual async bus purge of a key.
getLastError()
Get the "last error" registered; clearLastError() should be called manually.
BagOStuff $cache
The local datacenter cache.
isValid( $value, $versioned, $asOf, $minTime)
Check whether $value is appropriately versioned and not older than $minTime (if set)
processCheckKeys(array $timeKeys, array $wrappedValues, $now)
doGetWithSetCallback( $key, $ttl, $callback, array $opts, &$asOf=null)
Do the actual I/O for getWithSetCallback() when needed.
const HOLDOFF_NONE
Idiom for delete() for "no hold-off".
getMulti(array $keys, &$curTTLs=[], array $checkKeys=[], array &$asOfs=[])
Fetch the value of several keys from cache.
getCheckKeyTime( $key)
Fetch the value of a timestamp "check" key.
HashBagOStuff[] $processCaches
Map of group PHP instance caches.
relayDelete( $key)
Do the actual async bus delete of a key.
static parsePurgeValue( $value)
const LOCK_TTL
Seconds to keep lock keys around.
static prefixCacheKeys(array $keys, $prefix)
getMultiWithSetCallback(ArrayIterator $keyedIds, $ttl, callable $callback, array $opts=[])
Method to fetch/regenerate multiple cache keys at once.
const HIT_RATE_HIGH
Hits/second for a refresh to be expected within the "popularity" window.
EventRelayer $purgeRelayer
Bus that handles purge broadcasts.
static newEmpty()
Get an instance that wraps EmptyBagOStuff.
worthRefreshExpiring( $curTTL, $lowTTL)
Check if a key should be regenerated (using random probability)
getWithSetCallback( $key, $ttl, $callback, array $opts=[])
Method to fetch/regenerate cache keys.
makeMultiKeys(array $entities, callable $keyFunc)
const MAX_READ_LAG
Max replication+snapshot lag before applying TTL_LAGGED or disallowing set()
const CHECK_KEY_TTL
Seconds to keep dependency purge keys around.
const MIN_TIMESTAMP_NONE
Idiom for getWithSetCallback() for "no minimum required as-of timestamp".
const DEFAULT_PURGE_CHANNEL
clearProcessCache()
Clear the in-process caches; useful for testing.
wrap( $value, $ttl, $now)
Do not use this method outside WANObjectCache.
int $lastRelayError
ERR_* constant for the "last error" registry.
string $purgeChannel
Purge channel name.
reap( $key, $purgeTimestamp, &$isStale=false)
Locally set a key to expire soon if it is stale based on $purgeTimestamp.
makePurgeValue( $timestamp, $holdoff)
setLogger(LoggerInterface $logger)
reapCheckKey( $key, $purgeTimestamp, &$isStale=false)
Locally set a "check" key to expire soon if it is stale based on $purgeTimestamp.
integer $callbackDepth
Callback stack depth for getWithSetCallback()
clearLastError()
Clear the "last error" registry.
const TSE_NONE
Idiom for getWithSetCallback() callbacks to 'lockTSE' logic.
resetCheckKey( $key)
Delete a "check" key from all datacenters, invalidating keys that use it.
const MAX_COMMIT_DELAY
Max time expected to pass between delete() and DB commit finishing.
const AGE_NEW
Never consider performing "popularity" refreshes until a key reaches this age.
const RAMPUP_TTL
Seconds to ramp up to the "popularity" refresh chance after a key is no longer new.
const TTL_LAGGED
Max TTL to store keys when a data sourced is lagged.
deferred txt A few of the database updates required by various functions here can be deferred until after the result page is displayed to the user For updating the view updating the linked to tables after a etc PHP does not yet have any way to tell the server to actually return and disconnect while still running these but it might have such a feature in the future We handle these by creating a deferred update object and putting those objects on a global list
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
the array() calling protocol came about after MediaWiki 1.4rc1.
see documentation in includes Linker php for Linker::makeImageLink & $time
The index of the header message $result[1]=The index of the body text message $result[2 through n]=Parameters passed to body text message. Please note the header message cannot receive/use parameters. 'ImportHandleLogItemXMLTag':When parsing a XML tag in a log item. Return false to stop further processing of the tag $reader:XMLReader object $logInfo:Array of information 'ImportHandlePageXMLTag':When parsing a XML tag in a page. Return false to stop further processing of the tag $reader:XMLReader object & $pageInfo:Array of information 'ImportHandleRevisionXMLTag':When parsing a XML tag in a page revision. Return false to stop further processing of the tag $reader:XMLReader object $pageInfo:Array of page information $revisionInfo:Array of revision information 'ImportHandleToplevelXMLTag':When parsing a top level XML tag. Return false to stop further processing of the tag $reader:XMLReader object 'ImportHandleUploadXMLTag':When parsing a XML tag in a file upload. Return false to stop further processing of the tag $reader:XMLReader object $revisionInfo:Array of information 'ImportLogInterwikiLink':Hook to change the interwiki link used in log entries and edit summaries for transwiki imports. & $fullInterwikiPrefix:Interwiki prefix, may contain colons. & $pageTitle:String that contains page title. 'ImportSources':Called when reading from the $wgImportSources configuration variable. Can be used to lazy-load the import sources list. & $importSources:The value of $wgImportSources. Modify as necessary. See the comment in DefaultSettings.php for the detail of how to structure this array. 'InfoAction':When building information to display on the action=info page. $context:IContextSource object & $pageInfo:Array of information 'InitializeArticleMaybeRedirect':MediaWiki check to see if title is a redirect. & $title:Title object for the current page & $request:WebRequest & $ignoreRedirect:boolean to skip redirect check & $target:Title/string of redirect target & $article:Article object 'InternalParseBeforeLinks':during Parser 's internalParse method before links but after nowiki/noinclude/includeonly/onlyinclude and other processings. & $parser:Parser object & $text:string containing partially parsed text & $stripState:Parser 's internal StripState object 'InternalParseBeforeSanitize':during Parser 's internalParse method just before the parser removes unwanted/dangerous HTML tags and after nowiki/noinclude/includeonly/onlyinclude and other processings. Ideal for syntax-extensions after template/parser function execution which respect nowiki and HTML-comments. & $parser:Parser object & $text:string containing partially parsed text & $stripState:Parser 's internal StripState object 'InterwikiLoadPrefix':When resolving if a given prefix is an interwiki or not. Return true without providing an interwiki to continue interwiki search. $prefix:interwiki prefix we are looking for. & $iwData:output array describing the interwiki with keys iw_url, iw_local, iw_trans and optionally iw_api and iw_wikiid. 'InvalidateEmailComplete':Called after a user 's email has been invalidated successfully. $user:user(object) whose email is being invalidated 'IRCLineURL':When constructing the URL to use in an IRC notification. Callee may modify $url and $query, URL will be constructed as $url . $query & $url:URL to index.php & $query:Query string $rc:RecentChange object that triggered url generation 'IsFileCacheable':Override the result of Article::isFileCacheable()(if true) & $article:article(object) being checked 'IsTrustedProxy':Override the result of IP::isTrustedProxy() & $ip:IP being check & $result:Change this value to override the result of IP::isTrustedProxy() 'IsUploadAllowedFromUrl':Override the result of UploadFromUrl::isAllowedUrl() $url:URL used to upload from & $allowed:Boolean indicating if uploading is allowed for given URL 'isValidEmailAddr':Override the result of Sanitizer::validateEmail(), for instance to return false if the domain name doesn 't match your organization. $addr:The e-mail address entered by the user & $result:Set this and return false to override the internal checks 'isValidPassword':Override the result of User::isValidPassword() $password:The password entered by the user & $result:Set this and return false to override the internal checks $user:User the password is being validated for 'Language::getMessagesFileName':$code:The language code or the language we 're looking for a messages file for & $file:The messages file path, you can override this to change the location. 'LanguageGetMagic':DEPRECATED! Use $magicWords in a file listed in $wgExtensionMessagesFiles instead. Use this to define synonyms of magic words depending of the language & $magicExtensions:associative array of magic words synonyms $lang:language code(string) 'LanguageGetNamespaces':Provide custom ordering for namespaces or remove namespaces. Do not use this hook to add namespaces. Use CanonicalNamespaces for that. & $namespaces:Array of namespaces indexed by their numbers 'LanguageGetSpecialPageAliases':DEPRECATED! Use $specialPageAliases in a file listed in $wgExtensionMessagesFiles instead. Use to define aliases of special pages names depending of the language & $specialPageAliases:associative array of magic words synonyms $lang:language code(string) 'LanguageGetTranslatedLanguageNames':Provide translated language names. & $names:array of language code=> language name $code:language of the preferred translations 'LanguageLinks':Manipulate a page 's language links. This is called in various places to allow extensions to define the effective language links for a page. $title:The page 's Title. & $links:Array with elements of the form "language:title" in the order that they will be output. & $linkFlags:Associative array mapping prefixed links to arrays of flags. Currently unused, but planned to provide support for marking individual language links in the UI, e.g. for featured articles. 'LanguageSelector':Hook to change the language selector available on a page. $out:The output page. $cssClassName:CSS class name of the language selector. 'LinkBegin':DEPRECATED! Use HtmlPageLinkRendererBegin instead. Used when generating internal and interwiki links in Linker::link(), before processing starts. Return false to skip default processing and return $ret. See documentation for Linker::link() for details on the expected meanings of parameters. $skin:the Skin object $target:the Title that the link is pointing to & $html:the contents that the< a > tag should have(raw HTML) $result
This code would result in ircNotify being run twice when an article is and once for brion Hooks can return three possible true was required This is the default since MediaWiki *some string
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that probably a stub it is not rendered in wiki pages or galleries in category pages allow injecting custom HTML after the section Any uses of the hook need to handle escaping see BaseTemplate::getToolbox and BaseTemplate::makeListItem for details on the format of individual items inside of this array or by returning and letting standard HTTP rendering take place modifiable or by returning false and taking over the output modifiable & $code
it s the revision text itself In either if gzip is the revision text is gzipped $flags
processing should stop and the error should be shown to the user * false
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
Generic base class for storage interfaces.
you have access to all of the normal MediaWiki so you can get a DB use the cache