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.
 

Public Attributes

const CONSTRUCTOR_OPTIONS
 

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 93 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$thisSiteThe value of $thisSite, if $scope is 3.
Returns
array

Definition at line 325 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 131 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 381 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 155 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 121 of file ClassicInterwikiLookup.php.

References MediaWiki\Interwiki\ClassicInterwikiLookup\fetch().

Member Data Documentation

◆ CONSTRUCTOR_OPTIONS

const MediaWiki\Interwiki\ClassicInterwikiLookup::CONSTRUCTOR_OPTIONS
Initial value:
= [
'wikiId',
]
const InterwikiCache
Name constant for the InterwikiCache setting, for use with Config::get()
const InterwikiScopes
Name constant for the InterwikiScopes setting, for use with Config::get()
const InterwikiFallbackSite
Name constant for the InterwikiFallbackSite setting, for use with Config::get()
const InterwikiExpiry
Name constant for the InterwikiExpiry setting, for use with Config::get()
Access: internal
For use by ServiceWiring

Definition at line 51 of file ClassicInterwikiLookup.php.


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