176 $this->
cache = $params[
'cache'];
177 $this->purgeChannel = isset( $params[
'channels'][
'purge'] )
178 ? $params[
'channels'][
'purge']
179 : self::DEFAULT_PURGE_CHANNEL;
180 $this->purgeRelayer = isset( $params[
'relayers'][
'purge'] )
181 ? $params[
'relayers'][
'purge']
183 $this->
setLogger( isset( $params[
'logger'] ) ? $params[
'logger'] :
new NullLogger() );
243 final public function get( $key, &$curTTL = null,
array $checkKeys = [], &$asOf = null ) {
246 $values = $this->
getMulti( [ $key ], $curTTLs, $checkKeys, $asOfs );
247 $curTTL = isset( $curTTLs[$key] ) ? $curTTLs[$key] : null;
248 $asOf = isset( $asOfs[$key] ) ? $asOfs[$key] : null;
250 return isset( $values[$key] ) ? $values[$key] :
false;
272 $vPrefixLen = strlen( self::VALUE_KEY_PREFIX );
273 $valueKeys = self::prefixCacheKeys( $keys, self::VALUE_KEY_PREFIX );
275 $checkKeysForAll = [];
276 $checkKeysByKey = [];
278 foreach ( $checkKeys
as $i => $keys ) {
279 $prefixed = self::prefixCacheKeys( (
array)$keys, self::TIME_KEY_PREFIX );
280 $checkKeysFlat = array_merge( $checkKeysFlat, $prefixed );
282 if ( is_int( $i ) ) {
283 $checkKeysForAll = array_merge( $checkKeysForAll, $prefixed );
285 $checkKeysByKey[$i] = isset( $checkKeysByKey[$i] )
286 ? array_merge( $checkKeysByKey[$i], $prefixed )
292 $keysGet = array_merge( $valueKeys, $checkKeysFlat );
293 if ( $this->warmupCache ) {
294 $wrappedValues = array_intersect_key( $this->warmupCache, array_flip( $keysGet ) );
295 $keysGet = array_diff( $keysGet, array_keys( $wrappedValues ) );
299 $wrappedValues += $this->
cache->getMulti( $keysGet );
301 $now = microtime(
true );
304 $purgeValuesForAll = $this->
processCheckKeys( $checkKeysForAll, $wrappedValues, $now );
305 $purgeValuesByKey = [];
306 foreach ( $checkKeysByKey
as $cacheKey => $checks ) {
307 $purgeValuesByKey[$cacheKey] =
312 foreach ( $valueKeys
as $vKey ) {
313 if ( !isset( $wrappedValues[$vKey] ) ) {
317 $key = substr( $vKey, $vPrefixLen );
325 $purgeValues = $purgeValuesForAll;
326 if ( isset( $purgeValuesByKey[$key] ) ) {
327 $purgeValues = array_merge( $purgeValues, $purgeValuesByKey[$key] );
329 foreach ( $purgeValues
as $purge ) {
330 $safeTimestamp = $purge[self::FLD_TIME] + $purge[self::FLD_HOLDOFF];
331 if ( $safeTimestamp >= $wrappedValues[$vKey][self::FLD_TIME] ) {
333 $ago = min( $purge[self::FLD_TIME] - $now, self::TINY_NEGATIVE );
335 $curTTL = min( $curTTL, $ago );
339 $curTTLs[$key] = $curTTL;
340 $asOfs[$key] = (
$value !==
false ) ? $wrappedValues[$vKey][self::FLD_TIME] : null;
355 foreach ( $timeKeys
as $timeKey ) {
356 $purge = isset( $wrappedValues[$timeKey] )
357 ? self::parsePurgeValue( $wrappedValues[$timeKey] )
359 if ( $purge ===
false ) {
362 $this->
cache->add( $timeKey, $newVal, self::CHECK_KEY_TTL );
363 $purge = self::parsePurgeValue( $newVal );
365 $purgeValues[] = $purge;
429 $now = microtime(
true );
430 $lockTSE = isset( $opts[
'lockTSE'] ) ? $opts[
'lockTSE'] : self::TSE_NONE;
431 $age = isset( $opts[
'since'] ) ? max( 0, $now - $opts[
'since'] ) : 0;
432 $lag = isset( $opts[
'lag'] ) ? $opts[
'lag'] : 0;
433 $staleTTL = isset( $opts[
'staleTTL'] ) ? $opts[
'staleTTL'] : 0;
436 if ( !empty( $opts[
'pending'] ) ) {
437 $this->logger->info(
"Rejected set() for $key due to pending writes." );
444 if ( $lag ===
false || ( $lag + $age ) > self::MAX_READ_LAG ) {
446 if ( $lockTSE >= 0 ) {
447 $ttl = max( 1, (
int)$lockTSE );
448 $wrapExtra[self::FLD_FLAGS] = self::FLG_STALE;
450 } elseif ( $age > self::MAX_READ_LAG ) {
451 $this->logger->warning(
"Rejected set() for $key due to snapshot lag." );
455 } elseif ( $lag ===
false || $lag > self::MAX_READ_LAG ) {
456 $ttl = $ttl ? min( $ttl, self::TTL_LAGGED ) : self::TTL_LAGGED;
457 $this->logger->warning(
"Lowered set() TTL for $key due to replication lag." );
460 $this->logger->warning(
"Rejected set() for $key due to high read lag." );
467 $wrapped = $this->
wrap(
$value, $ttl, $now ) + $wrapExtra;
469 $func =
function (
$cache, $key, $cWrapped )
use ( $wrapped ) {
470 return ( is_string( $cWrapped ) )
475 return $this->
cache->merge( self::VALUE_KEY_PREFIX . $key, $func, $ttl + $staleTTL, 1 );
535 final public function delete( $key, $ttl = self::HOLDOFF_TTL ) {
536 $key = self::VALUE_KEY_PREFIX . $key;
543 $ok = $this->
relayPurge( $key, $ttl, self::HOLDOFF_NONE );
569 $key = self::TIME_KEY_PREFIX . $key;
571 $purge = self::parsePurgeValue( $this->
cache->get( $key ) );
572 if ( $purge !==
false ) {
573 $time = $purge[self::FLD_TIME];
576 $now = (
string)microtime(
true );
577 $this->
cache->add( $key,
622 return $this->
relayPurge( self::TIME_KEY_PREFIX . $key, self::CHECK_KEY_TTL, $holdoff );
657 return $this->
relayDelete( self::TIME_KEY_PREFIX . $key );
850 $pcTTL = isset( $opts[
'pcTTL'] ) ? $opts[
'pcTTL'] : self::TTL_UNCACHEABLE;
855 if ( $pcTTL >= 0 && $this->callbackDepth == 0 ) {
856 $group = isset( $opts[
'pcGroup'] ) ? $opts[
'pcGroup'] : self::PC_PRIMARY;
858 $value = $procCache->get( $key );
866 if ( isset( $opts[
'version'] ) ) {
867 $version = $opts[
'version'];
872 function ( $oldValue, &$ttl, &$setOpts, $oldAsOf )
873 use ( $callback, $version ) {
874 if ( is_array( $oldValue )
875 && array_key_exists( self::VFLD_DATA, $oldValue )
877 $oldData = $oldValue[self::VFLD_DATA];
884 self::VFLD_DATA => $callback( $oldData, $ttl, $setOpts, $oldAsOf ),
885 self::VFLD_VERSION => $version
891 if ( $cur[self::VFLD_VERSION] === $version ) {
893 $value = $cur[self::VFLD_DATA];
898 'cache-variant:' . md5( $key ) .
":$version",
902 [
'version' => null,
'minAsOf' => $asOf ] + $opts
910 if ( $procCache &&
$value !==
false ) {
911 $procCache->set( $key,
$value, $pcTTL );
932 $lowTTL = isset( $opts[
'lowTTL'] ) ? $opts[
'lowTTL'] : min( self::LOW_TTL, $ttl );
933 $lockTSE = isset( $opts[
'lockTSE'] ) ? $opts[
'lockTSE'] : self::TSE_NONE;
934 $checkKeys = isset( $opts[
'checkKeys'] ) ? $opts[
'checkKeys'] : [];
935 $busyValue = isset( $opts[
'busyValue'] ) ? $opts[
'busyValue'] : null;
936 $popWindow = isset( $opts[
'hotTTR'] ) ? $opts[
'hotTTR'] : self::HOT_TTR;
937 $ageNew = isset( $opts[
'ageNew'] ) ? $opts[
'ageNew'] : self::AGE_NEW;
938 $minTime = isset( $opts[
'minAsOf'] ) ? $opts[
'minAsOf'] : self::MIN_TIMESTAMP_NONE;
939 $versioned = isset( $opts[
'version'] );
943 $cValue = $this->
get( $key, $curTTL, $checkKeys, $asOf );
946 $preCallbackTime = microtime(
true );
958 $isTombstone = ( $curTTL !== null &&
$value ===
false );
960 $isHot = ( $curTTL !== null && $curTTL <= 0 && abs( $curTTL ) <= $lockTSE );
962 $checkBusy = ( $busyValue !== null && $value ===
false );
967 $useMutex = ( $isHot || ( $isTombstone && $lockTSE > 0 ) || $checkBusy );
969 $lockAcquired =
false;
972 if ( $this->
cache->add( self::MUTEX_KEY_PREFIX . $key, 1, self::LOCK_TTL ) ) {
974 $lockAcquired =
true;
975 } elseif ( $value !==
false && $this->
isValid( $value, $versioned, $asOf, $minTime ) ) {
982 $wrapped = $this->
cache->get( self::INTERIM_KEY_PREFIX . $key );
983 list( $value ) = $this->
unwrap( $wrapped, microtime(
true ) );
984 if ( $value !==
false && $this->
isValid( $value, $versioned, $asOf, $minTime ) ) {
985 $asOf = $wrapped[self::FLD_TIME];
990 if ( $busyValue !== null ) {
991 return is_callable( $busyValue ) ? $busyValue() : $busyValue;
996 if ( !is_callable( $callback ) ) {
1004 $value = call_user_func_array( $callback, [ $cValue, &$ttl, &$setOpts, $asOf ] );
1010 if ( ( $isTombstone && $lockTSE > 0 ) && $value !==
false && $ttl >= 0 ) {
1011 $tempTTL = max( 1, (
int)$lockTSE );
1012 $newAsOf = microtime(
true );
1013 $wrapped = $this->
wrap( $value, $tempTTL, $newAsOf );
1015 $this->
cache->merge(
1016 self::INTERIM_KEY_PREFIX . $key,
1017 function ()
use ( $wrapped ) {
1025 if ( $value !==
false && $ttl >= 0 ) {
1026 $setOpts[
'lockTSE'] = $lockTSE;
1028 $setOpts += [
'since' => $preCallbackTime ];
1030 $this->
set( $key, $value, $ttl, $setOpts );
1033 if ( $lockAcquired ) {
1035 $this->
cache->changeTTL( self::MUTEX_KEY_PREFIX . $key, 1 );
1099 ArrayIterator $keyedIds, $ttl, callable $callback,
array $opts = []
1101 $keysWarmUp = iterator_to_array( $keyedIds,
true );
1102 $checkKeys = isset( $opts[
'checkKeys'] ) ? $opts[
'checkKeys'] : [];
1103 foreach ( $checkKeys
as $i => $checkKeyOrKeys ) {
1104 if ( is_int( $i ) ) {
1105 $keysWarmUp[] = $checkKeyOrKeys;
1107 $keysWarmUp = array_merge( $keysWarmUp, $checkKeyOrKeys );
1111 $this->warmupCache = $this->
cache->getMulti( $keysWarmUp );
1112 $this->warmupCache += array_fill_keys( $keysWarmUp,
false );
1116 $func =
function ( $oldValue, &$ttl,
array $setOpts, $oldAsOf )
use ( $callback, &$id ) {
1117 return $callback( $id, $oldValue, $ttl, $setOpts, $oldAsOf );
1121 foreach ( $keyedIds
as $key => $id ) {
1125 $this->warmupCache = [];
1137 return call_user_func_array( [ $this->
cache, __FUNCTION__ ], func_get_args() );
1147 return call_user_func_array( [ $this->
cache, __FUNCTION__ ], func_get_args() );
1158 foreach ( $entities
as $entity ) {
1159 $map[$keyFunc( $entity, $this )] = $entity;
1162 return new ArrayIterator( $map );
1170 if ( $this->lastRelayError ) {
1182 return self::ERR_NONE;
1184 return self::ERR_NO_RESPONSE;
1186 return self::ERR_UNREACHABLE;
1188 return self::ERR_UNEXPECTED;
1196 $this->
cache->clearLastError();
1197 $this->lastRelayError = self::ERR_NONE;
1206 $this->processCaches = [];
1215 return $this->
cache->getQoS( $flag );
1241 public function adaptiveTTL( $mtime, $maxTTL, $minTTL = 30, $factor = .2 ) {
1242 if ( is_float( $mtime ) || ctype_digit( $mtime ) ) {
1243 $mtime = (int)$mtime;
1246 if ( !is_int( $mtime ) || $mtime <= 0 ) {
1250 $age = time() - $mtime;
1252 return (
int)min( $maxTTL, max( $minTTL, $factor * $age ) );
1268 $ok = $this->
cache->set( $key,
1273 $event = $this->
cache->modifySimpleRelayEvent( [
1276 'val' =>
'PURGED:$UNIXTIME$:' . (
int)$holdoff,
1277 'ttl' => max( $ttl, 1 ),
1281 $ok = $this->purgeRelayer->notify( $this->purgeChannel, $event );
1283 $this->lastRelayError = self::ERR_RELAY;
1299 $ok = $this->
cache->delete( $key );
1301 $event = $this->
cache->modifySimpleRelayEvent( [
1306 $ok = $this->purgeRelayer->notify( $this->purgeChannel, $event );
1308 $this->lastRelayError = self::ERR_RELAY;
1328 if ( $curTTL >= $lowTTL ) {
1330 } elseif ( $curTTL <= 0 ) {
1334 $chance = ( 1 - $curTTL / $lowTTL );
1336 return mt_rand( 1, 1e9 ) <= 1e9 * $chance;
1355 $age = $now - $asOf;
1356 $timeOld = $age - $ageNew;
1357 if ( $timeOld <= 0 ) {
1362 $refreshWindowSec = max( $timeTillRefresh - $ageNew - self::RAMPUP_TTL / 2, 1 );
1366 $chance = 1 / ( self::HIT_RATE_HIGH * $refreshWindowSec );
1369 $chance *= ( $timeOld <= self::RAMPUP_TTL ) ? $timeOld / self::RAMPUP_TTL : 1;
1371 return mt_rand( 1, 1e9 ) <= 1e9 * $chance;
1384 if ( $versioned && !isset(
$value[self::VFLD_VERSION] ) ) {
1386 } elseif ( $minTime > 0 && $asOf < $minTime ) {
1403 self::FLD_VERSION => self::VERSION,
1404 self::FLD_VALUE =>
$value,
1405 self::FLD_TTL => $ttl,
1406 self::FLD_TIME => $now
1417 protected function unwrap( $wrapped, $now ) {
1419 $purge = self::parsePurgeValue( $wrapped );
1420 if ( $purge !==
false ) {
1422 $curTTL = min( $purge[self::FLD_TIME] - $now, self::TINY_NEGATIVE );
1423 return [
false, $curTTL ];
1426 if ( !is_array( $wrapped )
1427 || !isset( $wrapped[self::FLD_VERSION] )
1428 || $wrapped[self::FLD_VERSION] !== self::VERSION
1430 return [
false, null ];
1433 $flags = isset( $wrapped[self::FLD_FLAGS] ) ? $wrapped[self::FLD_FLAGS] : 0;
1434 if ( (
$flags & self::FLG_STALE ) == self::FLG_STALE ) {
1436 $age = $now - $wrapped[self::FLD_TIME];
1437 $curTTL = min( -$age, self::TINY_NEGATIVE );
1438 } elseif ( $wrapped[self::FLD_TTL] > 0 ) {
1440 $age = $now - $wrapped[self::FLD_TIME];
1441 $curTTL = max( $wrapped[self::FLD_TTL] - $age, 0.0 );
1447 return [ $wrapped[self::FLD_VALUE], $curTTL ];
1457 foreach ( $keys
as $key ) {
1458 $res[] = $prefix . $key;
1470 if ( !is_string(
$value ) ) {
1473 $segments = explode(
':',
$value, 3 );
1474 if ( !isset( $segments[0] ) || !isset( $segments[1] )
1475 ||
"{$segments[0]}:" !== self::PURGE_VAL_PREFIX
1479 if ( !isset( $segments[2] ) ) {
1481 $segments[2] = self::HOLDOFF_TTL;
1484 self::FLD_TIME => (float)$segments[1],
1485 self::FLD_HOLDOFF => (
int)$segments[2],
1495 return self::PURGE_VAL_PREFIX . (float)
$timestamp .
':' . (
int)$holdoff;
1503 if ( !isset( $this->processCaches[$group] ) ) {
1504 list( , $n ) = explode(
':', $group );
1505 $this->processCaches[$group] =
new HashBagOStuff( [
'maxKeys' => (
int)$n ] );
1508 return $this->processCaches[$group];
processCheckKeys(array $timeKeys, array $wrappedValues, $now)
set($key, $value, $ttl=0, array $opts=[])
Set the value of a key in cache.
string $purgeChannel
Purge channel name.
doGetWithSetCallback($key, $ttl, $callback, array $opts, &$asOf=null)
Do the actual I/O for getWithSetCallback() when needed.
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
const TTL_LAGGED
Max TTL to store keys when a data sourced is lagged.
const TINY_NEGATIVE
Tiny negative float to use when CTL comes up >= 0 due to clock skew.
the array() calling protocol came about after MediaWiki 1.4rc1.
const CHECK_KEY_TTL
Seconds to keep dependency purge keys around.
processing should stop and the error should be shown to the user * false
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
clearProcessCache()
Clear the in-process caches; useful for testing.
integer $callbackDepth
Callback stack depth for getWithSetCallback()
static prefixCacheKeys(array $keys, $prefix)
adaptiveTTL($mtime, $maxTTL, $minTTL=30, $factor=.2)
Get a TTL that is higher for objects that have not changed recently.
unwrap($wrapped, $now)
Do not use this method outside WANObjectCache.
const MAX_COMMIT_DELAY
Max time expected to pass between delete() and DB commit finishing.
const TTL_UNCACHEABLE
Idiom for getWithSetCallback() callbacks to avoid calling set()
mixed[] $warmupCache
Temporary warm-up cache.
EventRelayer $purgeRelayer
Bus that handles purge broadcasts.
getMultiWithSetCallback(ArrayIterator $keyedIds, $ttl, callable $callback, array $opts=[])
Method to fetch/regenerate multiple cache keys at once.
touchCheckKey($key, $holdoff=self::HOLDOFF_TTL)
Purge a "check" key from all datacenters, invalidating keys that use it.
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
const DEFAULT_PURGE_CHANNEL
it s the revision text itself In either if gzip is the revision text is gzipped $flags
No-op class for publishing messages into a PubSub system.
getWithSetCallback($key, $ttl, $callback, array $opts=[])
Method to fetch/regenerate cache keys.
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:Associative array mapping language codes to prefixed links of the form"language:title".&$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
you have access to all of the normal MediaWiki so you can get a DB use the cache
static newEmpty()
Get an instance that wraps EmptyBagOStuff.
const LOW_TTL
Default remaining TTL at which to consider pre-emptive regeneration.
getLastError()
Get the "last error" registered; clearLastError() should be called manually.
__construct(array $params)
const RAMPUP_TTL
Seconds to ramp up to the "popularity" refresh chance after a key is no longer new.
const ERR_NONE
Possible values for getLastError()
getCheckKeyTime($key)
Fetch the value of a timestamp "check" key.
const LOCK_TSE
Default time-since-expiry on a miss that makes a key "hot".
A BagOStuff object with no objects in it.
const HOLDOFF_NONE
Idiom for delete() for "no hold-off".
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
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
isValid($value, $versioned, $asOf, $minTime)
Check whether $value is appropriately versioned and not older than $minTime (if set) ...
const VERSION
Cache format version number.
clearLastError()
Clear the "last error" registry.
resetCheckKey($key)
Delete a "check" key from all datacenters, invalidating keys that use it.
const HOLDOFF_TTL
Seconds to tombstone keys on delete()
const MIN_TIMESTAMP_NONE
Idiom for getWithSetCallback() for "no minimum required as-of timestamp".
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
relayPurge($key, $ttl, $holdoff)
Do the actual async bus purge of a key.
int $lastRelayError
ERR_* constant for the "last error" registry.
worthRefreshPopular($asOf, $ageNew, $timeTillRefresh, $now)
Check if a key is due for randomized regeneration due to its popularity.
wrap($value, $ttl, $now)
Do not use this method outside WANObjectCache.
const HOT_TTR
The time length of the "popularity" refresh window for hot keys.
const AGE_NEW
Never consider performing "popularity" refreshes until a key reaches this age.
static parsePurgeValue($value)
const LOCK_TTL
Seconds to keep lock keys around.
worthRefreshExpiring($curTTL, $lowTTL)
Check if a key should be regenerated (using random probability)
makePurgeValue($timestamp, $holdoff)
getMulti(array $keys, &$curTTLs=[], array $checkKeys=[], array &$asOfs=[])
Fetch the value of several keys from cache.
relayDelete($key)
Do the actual async bus delete of a key.
Generic base class for storage interfaces.
const MAX_READ_LAG
Max replication+snapshot lag before applying TTL_LAGGED or disallowing set()
setLogger(LoggerInterface $logger)
const TSE_NONE
Idiom for getWithSetCallback() callbacks to 'lockTSE' logic.
const HIT_RATE_HIGH
Hits/second for a refresh to be expected within the "popularity" window.
makeMultiKeys(array $entities, callable $keyFunc)
see documentation in includes Linker php for Linker::makeImageLink & $time
BagOStuff $cache
The local datacenter cache.
HashBagOStuff[] $processCaches
Map of group PHP instance caches.