MediaWiki  master
MediaWiki\Linker\LinkTargetStore Class Reference

Service for retrieving and storing link targets. More...

Inheritance diagram for MediaWiki\Linker\LinkTargetStore:
Collaboration diagram for MediaWiki\Linker\LinkTargetStore:

Public Member Functions

 acquireLinkTargetId (LinkTarget $linkTarget, IDatabase $dbw)
 Attempt to assign a link target ID to the given $linkTarget. More...
 
 clearClassCache ()
 
 getLinkTargetById (int $linkTargetId)
 Find a link target by $id. More...
 
 getLinkTargetId (LinkTarget $linkTarget)
 Return link target id if exists. More...
 
 newLinkTargetFromRow (stdClass $row)
 Instantiate a new LinkTarget object based on a $row from the linktarget table.Use this method when a linktarget row was already fetched from the DB via a join. This method just constructs a new instance and does not try fetching missing values from the DB again.
Parameters
stdClass$rowwith the following fields:
  • int lt_id
  • int lt_namespace
  • string lt_title
Returns
LinkTarget
More...
 

Public Attributes

$this byIdCache = []
 
$this byTitleCache = []
 
$this wanObjectCache = $WanObjectCache
 

Private Member Functions

 addToClassCache (int $id, LinkTarget $linkTarget)
 
 fetchIdFromDbPrimary (LinkTarget $linkTarget, array $queryOptions=[])
 Find lt_id of the given $linkTarget. More...
 
 getLinkTargetIdFromCache (LinkTarget $linkTarget)
 

Private Attributes

ILoadBalancer $loadBalancer
 
BagOStuff $localCache
 
WANObjectCache $wanObjectCache
 
array< int, $byIdCache;private array< string, $byTitleCache;public function __construct(ILoadBalancer $loadBalancer, BagOStuff $localCache, WANObjectCache $WanObjectCache) { $this->loadBalancer=$loadBalancer;$this-> localCache = $localCache
 LinkTarget> More...
 

Detailed Description

Service for retrieving and storing link targets.

Since
1.38

Definition at line 37 of file LinkTargetStore.php.

Member Function Documentation

◆ acquireLinkTargetId()

MediaWiki\Linker\LinkTargetStore::acquireLinkTargetId ( LinkTarget  $linkTarget,
IDatabase  $dbw 
)

Attempt to assign a link target ID to the given $linkTarget.

If it is already assigned, return the existing ID.

Note
If called within a transaction, the returned ID might become invalid if the transaction is rolled back, so it should not be passed outside of the transaction context.
Parameters
LinkTarget$linkTarget
IDatabase$dbwThe database connection to acquire the ID from.
Returns
int linktarget ID greater then 0
Exceptions
RuntimeExceptionif no linktarget ID has been assigned to this $linkTarget

Implements MediaWiki\Linker\LinkTargetLookup.

Definition at line 146 of file LinkTargetStore.php.

◆ addToClassCache()

MediaWiki\Linker\LinkTargetStore::addToClassCache ( int  $id,
LinkTarget  $linkTarget 
)
private

Definition at line 224 of file LinkTargetStore.php.

◆ clearClassCache()

MediaWiki\Linker\LinkTargetStore::clearClassCache ( )

Definition at line 232 of file LinkTargetStore.php.

◆ fetchIdFromDbPrimary()

MediaWiki\Linker\LinkTargetStore::fetchIdFromDbPrimary ( LinkTarget  $linkTarget,
array  $queryOptions = [] 
)
private

Find lt_id of the given $linkTarget.

Parameters
LinkTarget$linkTarget
array$queryOptions
Returns
int|null

Definition at line 201 of file LinkTargetStore.php.

◆ getLinkTargetById()

MediaWiki\Linker\LinkTargetStore::getLinkTargetById ( int  $linkTargetId)

Find a link target by $id.

Parameters
int$linkTargetId
Returns
LinkTarget|null Returns null if no link target with this $linkTargetId exists in the database.

Implements MediaWiki\Linker\LinkTargetLookup.

Definition at line 93 of file LinkTargetStore.php.

◆ getLinkTargetId()

MediaWiki\Linker\LinkTargetStore::getLinkTargetId ( LinkTarget  $linkTarget)

Return link target id if exists.

Parameters
LinkTarget$linkTarget
Returns
int|null linktarget ID greater then 0, null if not found

Implements MediaWiki\Linker\LinkTargetLookup.

Definition at line 124 of file LinkTargetStore.php.

◆ getLinkTargetIdFromCache()

MediaWiki\Linker\LinkTargetStore::getLinkTargetIdFromCache ( LinkTarget  $linkTarget)
private

Definition at line 237 of file LinkTargetStore.php.

References $res, and DB_REPLICA.

◆ newLinkTargetFromRow()

MediaWiki\Linker\LinkTargetStore::newLinkTargetFromRow ( stdClass  $row)

Instantiate a new LinkTarget object based on a $row from the linktarget table.Use this method when a linktarget row was already fetched from the DB via a join. This method just constructs a new instance and does not try fetching missing values from the DB again.

Parameters
stdClass$rowwith the following fields:
  • int lt_id
  • int lt_namespace
  • string lt_title
Returns
LinkTarget

Implements MediaWiki\Linker\LinkTargetLookup.

Definition at line 74 of file LinkTargetStore.php.

Member Data Documentation

◆ $loadBalancer

ILoadBalancer MediaWiki\Linker\LinkTargetStore::$loadBalancer
private

Definition at line 40 of file LinkTargetStore.php.

◆ $localCache

BagOStuff MediaWiki\Linker\LinkTargetStore::$localCache
private

Definition at line 43 of file LinkTargetStore.php.

◆ $wanObjectCache

WANObjectCache MediaWiki\Linker\LinkTargetStore::$wanObjectCache
private

Definition at line 46 of file LinkTargetStore.php.

◆ byIdCache

$this MediaWiki\Linker\LinkTargetStore::byIdCache = []

Definition at line 67 of file LinkTargetStore.php.

◆ byTitleCache

$this MediaWiki\Linker\LinkTargetStore::byTitleCache = []

Definition at line 68 of file LinkTargetStore.php.

◆ localCache

array<int, $byIdCache; private array<string, $byTitleCache; public function __construct( ILoadBalancer $loadBalancer, BagOStuff $localCache, WANObjectCache $WanObjectCache ) { $this->loadBalancer = $loadBalancer; $this-> MediaWiki\Linker\LinkTargetStore::localCache = $localCache
private

LinkTarget>

Definition at line 65 of file LinkTargetStore.php.

◆ wanObjectCache

$this MediaWiki\Linker\LinkTargetStore::wanObjectCache = $WanObjectCache

Definition at line 66 of file LinkTargetStore.php.


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