Wikibase
MediaWiki Wikibase extension
Loading...
Searching...
No Matches
Wikibase\Repo\Store\BagOStuffSiteLinkConflictLookup Class Reference

Short-term sitelink conflict lookup using a BagOStuff (e.g. More...

+ Inheritance diagram for Wikibase\Repo\Store\BagOStuffSiteLinkConflictLookup:
+ Collaboration diagram for Wikibase\Repo\Store\BagOStuffSiteLinkConflictLookup:

Public Member Functions

 __construct (BagOStuff $bagOStuff)
 
 getConflictsForItem (ItemId $itemId, SiteLinkList $siteLinkList, int $db=null)
 Returns an array with the conflicts between the item and the sitelinks currently in the store.
 
 clearConflictsForItem (Item $item)
 Remove the item’s sitelinks from the BagOStuff.
 

Private Member Functions

 getConflictForSiteLink (string $itemId, SiteLink $siteLink)
 Try to write a sitelink to BagOStuff, returning a conflict array on failure.
 
 peekConflictForSiteLink (string $itemId, SiteLink $siteLink)
 Check if a sitelink is present in the BagOStuff without writing to it.
 
 clearConflictsForSiteLinks (array $siteLinks)
 
 cacheKey (SiteLink $siteLink)
 

Private Attributes

 $bagOStuff
 

Detailed Description

Short-term sitelink conflict lookup using a BagOStuff (e.g.

memcached).

When getConflictsForItem is called in write mode (with DB_PRIMARY), then the lookup will attempt to write each sitelink to the BagOStuff; any sitelink already present there will be reported as a conflict. The written sitelinks can later be removed by calling clearConflictsForItem.

Compared to SqlSiteLinkConflictLookup, this class detects conflicts earlier, but less reliably: its purpose is to prevent race conditions on simultaneous saves, before sitelinks have been written to the database (in a secondary data update).

Constructor & Destructor Documentation

◆ __construct()

Wikibase\Repo\Store\BagOStuffSiteLinkConflictLookup::__construct ( BagOStuff  $bagOStuff)

Member Function Documentation

◆ cacheKey()

Wikibase\Repo\Store\BagOStuffSiteLinkConflictLookup::cacheKey ( SiteLink  $siteLink)
private

◆ clearConflictsForItem()

Wikibase\Repo\Store\BagOStuffSiteLinkConflictLookup::clearConflictsForItem ( Item  $item)

Remove the item’s sitelinks from the BagOStuff.

This should be called after the sitelinks were written to wb_items_per_site (and after that write was committed).

◆ clearConflictsForSiteLinks()

Wikibase\Repo\Store\BagOStuffSiteLinkConflictLookup::clearConflictsForSiteLinks ( array  $siteLinks)
private

◆ getConflictForSiteLink()

Wikibase\Repo\Store\BagOStuffSiteLinkConflictLookup::getConflictForSiteLink ( string  $itemId,
SiteLink  $siteLink 
)
private

Try to write a sitelink to BagOStuff, returning a conflict array on failure.

◆ getConflictsForItem()

Wikibase\Repo\Store\BagOStuffSiteLinkConflictLookup::getConflictsForItem ( ItemId  $item,
SiteLinkList  $siteLinkList,
int  $db = null 
)

Returns an array with the conflicts between the item and the sitelinks currently in the store.

The array is empty if there are no such conflicts.

The items in the return array are arrays with the following elements:

  • ItemId|null itemId (null if not known)
  • string siteId
  • string sitePage
Parameters
ItemId$item
SiteLinkList$siteLinkList
int | null$dbThe database flag to use (optional). Use one of DB_PRIMARY or DB_REPLICA. DB_PRIMARY can be used when you need the most recent data.
Returns
array[] An array of arrays, each with the keys "siteId", "itemId" and "sitePage".

Implements Wikibase\Repo\Store\SiteLinkConflictLookup.

◆ peekConflictForSiteLink()

Wikibase\Repo\Store\BagOStuffSiteLinkConflictLookup::peekConflictForSiteLink ( string  $itemId,
SiteLink  $siteLink 
)
private

Check if a sitelink is present in the BagOStuff without writing to it.

Member Data Documentation

◆ $bagOStuff

Wikibase\Repo\Store\BagOStuffSiteLinkConflictLookup::$bagOStuff
private

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