MediaWiki master
MediaWiki\Interwiki\ClassicInterwikiLookup Class Reference

InterwikiLookup backed by the interwiki database table or $wgInterwikiCache. More...

Inherits MediaWiki\Interwiki\InterwikiLookup.

Collaboration diagram for MediaWiki\Interwiki\ClassicInterwikiLookup:

Public Member Functions

 __construct (ServiceOptions $options, Language $contLang, WANObjectCache $wanCache, HookContainer $hookContainer, IConnectionProvider $dbProvider)
 
 fetch ( $prefix)
 Get the Interwiki object for a given prefix.
Parameters
string$prefixInterwiki prefix
Returns
Interwiki|null|false Null for invalid, false for not found

 
 getAllPrefixes ( $local=null)
 Fetch all interwiki data.
 
 invalidateCache ( $prefix)
 Purge the instance cache and memcached for an interwiki prefix.
 
 isValidInterwiki ( $prefix)
 Check whether an interwiki prefix exists.
Parameters
string$prefixInterwiki prefix
Returns
bool Whether it exists

 

Static Public Member Functions

static buildCdbHash (array $allPrefixes, int $scope=1, ?string $thisSite=null)
 Build an array in the format accepted by $wgInterwikiCache.
 

Detailed Description

InterwikiLookup backed by the interwiki database table or $wgInterwikiCache.

By default this uses the SQL backend (interwiki database table) and includes two levels of caching. When parsing a wiki page, many interwiki lookups may be required and thus there is in-class caching for repeat lookups. To reduce database pressure, there is also WANObjectCache for each prefix.

Optionally, a pregenerated dataset can be statically set via $wgInterwikiCache, in which case there are no calls to either database or WANObjectCache.

Since
1.28

Definition at line 47 of file ClassicInterwikiLookup.php.

Constructor & Destructor Documentation

◆ __construct()

MediaWiki\Interwiki\ClassicInterwikiLookup::__construct ( ServiceOptions  $options,
Language  $contLang,
WANObjectCache  $wanCache,
HookContainer  $hookContainer,
IConnectionProvider  $dbProvider 
)
Parameters
ServiceOptions$options
Language$contLangLanguage object used to convert prefixes to lower case
WANObjectCache$wanCacheCache for interwiki info retrieved from the database
HookContainer$hookContainer
IConnectionProvider$dbProvider

Definition at line 94 of file ClassicInterwikiLookup.php.

References MediaWiki\Config\ServiceOptions\assertRequiredOptions(), MediaWiki\Config\ServiceOptions\get(), MediaWiki\MainConfigNames\InterwikiCache, and MediaWiki\MainConfigNames\InterwikiScopes.

Member Function Documentation

◆ buildCdbHash()

static MediaWiki\Interwiki\ClassicInterwikiLookup::buildCdbHash ( array  $allPrefixes,
int  $scope = 1,
?string  $thisSite = null 
)
static

Build an array in the format accepted by $wgInterwikiCache.

Given the array returned by getAllPrefixes(), build a PHP array which can be given to self::__construct() as $interwikiData, i.e. as the value of $wgInterwikiCache. This is used to construct mock interwiki lookup services for testing (in particular, parsertests).

Parameters
array$allPrefixesAn array of interwiki information such as would be returned by ::getAllPrefixes()
int$scopeThe scope at which to insert interwiki prefixes. See the $interwikiScopes parameter to ::__construct().
?string$thisSite The value of $thisSite, if $scope is 3.
Returns
array

Definition at line 326 of file ClassicInterwikiLookup.php.

◆ fetch()

MediaWiki\Interwiki\ClassicInterwikiLookup::fetch (   $prefix)

Get the Interwiki object for a given prefix.

Parameters
string$prefixInterwiki prefix
Returns
Interwiki|null|false Null for invalid, false for not found

Parameters
string | null$prefix
Returns
Interwiki|null|false

Implements MediaWiki\Interwiki\InterwikiLookup.

Definition at line 132 of file ClassicInterwikiLookup.php.

Referenced by MediaWiki\Interwiki\ClassicInterwikiLookup\isValidInterwiki().

◆ getAllPrefixes()

MediaWiki\Interwiki\ClassicInterwikiLookup::getAllPrefixes (   $local = null)

Fetch all interwiki data.

Parameters
string | null$localIf set, limit returned data to local or non-local interwikis
Returns
array[] Database-like interwiki rows

Implements MediaWiki\Interwiki\InterwikiLookup.

Definition at line 382 of file ClassicInterwikiLookup.php.

◆ invalidateCache()

MediaWiki\Interwiki\ClassicInterwikiLookup::invalidateCache (   $prefix)

Purge the instance cache and memcached for an interwiki prefix.

Note that memcached is not used when $wgInterwikiCache is enabled, as the pregenerated data will be used statically without need for memcached.

Parameters
string$prefix

Implements MediaWiki\Interwiki\InterwikiLookup.

Definition at line 156 of file ClassicInterwikiLookup.php.

◆ isValidInterwiki()

MediaWiki\Interwiki\ClassicInterwikiLookup::isValidInterwiki (   $prefix)

Check whether an interwiki prefix exists.

Parameters
string$prefixInterwiki prefix
Returns
bool Whether it exists

Parameters
string$prefix
Returns
bool

Implements MediaWiki\Interwiki\InterwikiLookup.

Definition at line 122 of file ClassicInterwikiLookup.php.

References MediaWiki\Interwiki\ClassicInterwikiLookup\fetch().


The documentation for this class was generated from the following file: