MediaWiki REL1_33
MediaWiki\Interwiki\ClassicInterwikiLookup Class Reference

InterwikiLookup implementing the "classic" interwiki storage (hardcoded up to MW 1.26). More...

Inheritance diagram for MediaWiki\Interwiki\ClassicInterwikiLookup:
Collaboration diagram for MediaWiki\Interwiki\ClassicInterwikiLookup:

Public Member Functions

 __construct (Language $contLang, WANObjectCache $objectCache, $objectCacheExpiry, $cdbData, $interwikiScopes, $fallbackSite)
 
 fetch ( $prefix)
 Fetch an Interwiki object.
 
 getAllPrefixes ( $local=null)
 Returns all interwiki prefixes.
 
 invalidateCache ( $prefix)
 Purge the in-process and object cache for an interwiki prefix.
 
 isValidInterwiki ( $prefix)
 Check whether an interwiki prefix exists.
 
 resetLocalCache ()
 Resets locally cached Interwiki objects.
 

Private Member Functions

 getAllPrefixesCached ( $local)
 Fetch all interwiki prefixes from interwiki cache.
 
 getAllPrefixesDB ( $local)
 Fetch all interwiki prefixes from DB.
 
 getCacheValue ( $key)
 
 getInterwikiCached ( $prefix)
 Fetch interwiki prefix data from local cache in constant database.
 
 getInterwikiCacheEntry ( $prefix)
 Get entry from interwiki cache.
 
 load ( $prefix)
 Load the interwiki, trying first memcached then the DB.
 
 loadFromArray ( $mc)
 Fill in member variables from an array (e.g.
 

Static Private Member Functions

static selectFields ()
 Return the list of interwiki fields that should be selected to create a new Interwiki object.
 

Private Attributes

bool array string $cdbData
 
CdbReader null $cdbReader = null
 
Language $contLang
 
string $fallbackSite
 
int $interwikiScopes
 
MapCacheLRU $localCache
 
WANObjectCache $objectCache
 
int $objectCacheExpiry
 
string null $thisSite = null
 

Detailed Description

InterwikiLookup implementing the "classic" interwiki storage (hardcoded up to MW 1.26).

This implements two levels of caching (in-process array and a WANObjectCache) and tree storage backends (SQL, CDB, and plain PHP arrays).

All information is loaded on creation when called by $this->fetch( $prefix ). All work is done on replica DB, because this should never change (except during schema updates etc, which aren't wiki-related)

Since
1.28

Definition at line 47 of file ClassicInterwikiLookup.php.

Constructor & Destructor Documentation

◆ __construct()

MediaWiki\Interwiki\ClassicInterwikiLookup::__construct ( Language $contLang,
WANObjectCache $objectCache,
$objectCacheExpiry,
$cdbData,
$interwikiScopes,
$fallbackSite )
Parameters
Language$contLangLanguage object used to convert prefixes to lower case
WANObjectCache$objectCacheCache for interwiki info retrieved from the database
int$objectCacheExpiryExpiry time for $objectCache, in seconds
bool | array | string$cdbDataThe path of a CDB file, or an array resembling the contents of a CDB file, or false to use the database.
int$interwikiScopesSpecify number of domains to check for messages:
  • 1: Just local wiki level
  • 2: wiki and global levels
  • 3: site level as well as wiki and global levels
string$fallbackSiteThe code to assume for the local site,

Definition at line 107 of file ClassicInterwikiLookup.php.

References MediaWiki\Interwiki\ClassicInterwikiLookup\$cdbData, MediaWiki\Interwiki\ClassicInterwikiLookup\$contLang, MediaWiki\Interwiki\ClassicInterwikiLookup\$fallbackSite, MediaWiki\Interwiki\ClassicInterwikiLookup\$interwikiScopes, MediaWiki\Interwiki\ClassicInterwikiLookup\$objectCache, and MediaWiki\Interwiki\ClassicInterwikiLookup\$objectCacheExpiry.

Member Function Documentation

◆ fetch()

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

Fetch an Interwiki object.

Parameters
string$prefixInterwiki prefix to use
Returns
Interwiki|null|bool

Implements MediaWiki\Interwiki\InterwikiLookup.

Definition at line 143 of file ClassicInterwikiLookup.php.

References and(), MediaWiki\Interwiki\ClassicInterwikiLookup\getInterwikiCached(), and load.

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

◆ getAllPrefixes()

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

Returns all interwiki prefixes.

Parameters
string | null$localIf set, limits output to local/non-local interwikis
Returns
array[] Interwiki rows, where each row is an associative array

Implements MediaWiki\Interwiki\InterwikiLookup.

Definition at line 436 of file ClassicInterwikiLookup.php.

References MediaWiki\Interwiki\ClassicInterwikiLookup\getAllPrefixesCached(), and MediaWiki\Interwiki\ClassicInterwikiLookup\getAllPrefixesDB().

◆ getAllPrefixesCached()

MediaWiki\Interwiki\ClassicInterwikiLookup::getAllPrefixesCached ( $local)
private

Fetch all interwiki prefixes from interwiki cache.

Parameters
null | string$localIf not null, limits output to local/non-local interwikis
Returns
array List of prefixes, where each row is an associative array

Definition at line 339 of file ClassicInterwikiLookup.php.

References $data, $e, MediaWiki\Interwiki\ClassicInterwikiLookup\$fallbackSite, $source, MediaWiki\Interwiki\ClassicInterwikiLookup\$thisSite, and(), MediaWiki\Interwiki\ClassicInterwikiLookup\getCacheValue(), list, and wfDebug().

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

◆ getAllPrefixesDB()

MediaWiki\Interwiki\ClassicInterwikiLookup::getAllPrefixesDB ( $local)
private

Fetch all interwiki prefixes from DB.

Parameters
string | null$localIf not null, limits output to local/non-local interwikis
Returns
array[] Interwiki rows

Definition at line 404 of file ClassicInterwikiLookup.php.

References $res, and(), array(), DB_REPLICA, and wfGetDB().

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

◆ getCacheValue()

MediaWiki\Interwiki\ClassicInterwikiLookup::getCacheValue ( $key)
private

◆ getInterwikiCached()

MediaWiki\Interwiki\ClassicInterwikiLookup::getInterwikiCached ( $prefix)
private

Fetch interwiki prefix data from local cache in constant database.

Note
More logic is explained in DefaultSettings.
Parameters
string$prefixInterwiki prefix
Returns
Interwiki|false

Definition at line 194 of file ClassicInterwikiLookup.php.

References $value, MediaWiki\Interwiki\ClassicInterwikiLookup\getInterwikiCacheEntry(), and list.

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

◆ getInterwikiCacheEntry()

MediaWiki\Interwiki\ClassicInterwikiLookup::getInterwikiCacheEntry ( $prefix)
private

Get entry from interwiki cache.

Note
More logic is explained in DefaultSettings.
Parameters
string$prefixDatabase key
Returns
bool|string The interwiki entry or false if not found

Definition at line 214 of file ClassicInterwikiLookup.php.

References $e, MediaWiki\Interwiki\ClassicInterwikiLookup\$fallbackSite, $value, MediaWiki\Interwiki\ClassicInterwikiLookup\getCacheValue(), and wfDebug().

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

◆ invalidateCache()

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

Purge the in-process and object cache for an interwiki prefix.

Parameters
string$prefix

Implements MediaWiki\Interwiki\InterwikiLookup.

Definition at line 179 of file ClassicInterwikiLookup.php.

◆ isValidInterwiki()

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

Check whether an interwiki prefix exists.

Parameters
string$prefixInterwiki prefix to use
Returns
bool Whether it exists

Implements MediaWiki\Interwiki\InterwikiLookup.

Definition at line 131 of file ClassicInterwikiLookup.php.

References $result, and MediaWiki\Interwiki\ClassicInterwikiLookup\fetch().

◆ load()

MediaWiki\Interwiki\ClassicInterwikiLookup::load ( $prefix)
private

Load the interwiki, trying first memcached then the DB.

Parameters
string$prefixThe interwiki prefix
Returns
Interwiki|bool Interwiki if $prefix is valid, otherwise false

Definition at line 273 of file ClassicInterwikiLookup.php.

References $dbr, $fname, and(), array(), DB_REPLICA, function, MediaWiki\Interwiki\ClassicInterwikiLookup\loadFromArray(), Hooks\run(), and wfGetDB().

◆ loadFromArray()

MediaWiki\Interwiki\ClassicInterwikiLookup::loadFromArray ( $mc)
private

Fill in member variables from an array (e.g.

memcached result, Database::fetchRow, etc)

Parameters
array$mcAssociative array: row from the interwiki table
Returns
Interwiki|bool Interwiki object or false if $mc['iw_url'] is not set

Definition at line 319 of file ClassicInterwikiLookup.php.

References and().

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

◆ resetLocalCache()

MediaWiki\Interwiki\ClassicInterwikiLookup::resetLocalCache ( )

Resets locally cached Interwiki objects.

This is intended for use during testing only. This does not invalidate entries in the persistent cache, as invalidateCache() does.

Since
1.27

Definition at line 171 of file ClassicInterwikiLookup.php.

◆ selectFields()

static MediaWiki\Interwiki\ClassicInterwikiLookup::selectFields ( )
staticprivate

Return the list of interwiki fields that should be selected to create a new Interwiki object.

Returns
string[]

Definition at line 449 of file ClassicInterwikiLookup.php.

Member Data Documentation

◆ $cdbData

bool array string MediaWiki\Interwiki\ClassicInterwikiLookup::$cdbData
private

◆ $cdbReader

CdbReader null MediaWiki\Interwiki\ClassicInterwikiLookup::$cdbReader = null
private

Definition at line 87 of file ClassicInterwikiLookup.php.

◆ $contLang

Language MediaWiki\Interwiki\ClassicInterwikiLookup::$contLang
private

◆ $fallbackSite

◆ $interwikiScopes

int MediaWiki\Interwiki\ClassicInterwikiLookup::$interwikiScopes
private

◆ $localCache

MapCacheLRU MediaWiki\Interwiki\ClassicInterwikiLookup::$localCache
private

Definition at line 52 of file ClassicInterwikiLookup.php.

◆ $objectCache

WANObjectCache MediaWiki\Interwiki\ClassicInterwikiLookup::$objectCache
private

◆ $objectCacheExpiry

int MediaWiki\Interwiki\ClassicInterwikiLookup::$objectCacheExpiry
private

◆ $thisSite

string null MediaWiki\Interwiki\ClassicInterwikiLookup::$thisSite = null
private

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