Wikibase
MediaWiki Wikibase extension
Wikibase\Lib\Store\Sql\Terms\TermInLangIdsAcquirer Interface Reference

Consumers acquire ids for stored terms to be used to link entities to these terms. More...

+ Inheritance diagram for Wikibase\Lib\Store\Sql\Terms\TermInLangIdsAcquirer:

Public Member Functions

 acquireTermInLangIds (array $termsArray, $callback=null)
 Acquires IDs for the given terms. More...
 

Detailed Description

Consumers acquire ids for stored terms to be used to link entities to these terms.

Member Function Documentation

◆ acquireTermInLangIds()

Wikibase\Lib\Store\Sql\Terms\TermInLangIdsAcquirer::acquireTermInLangIds ( array  $termsArray,
  $callback = null 
)

Acquires IDs for the given terms.

The acquirer guarantees that an in-parallel TermStoreCleaner will not result in deleting terms that have been acquired by this acquirer, should these two in-parallel processes happen to overlap on some existing term in lang IDs. The mechanism of achieving this guarantee is complete under the following two conditions:

  • External linking to acquired IDs (e.g. using them as foreign keys in other tables) must happen inside the $callback.
  • The in-parallel cleaner is called with set of IDs based on the absence of any links to those IDs, in the same external places where the callback links to them.
Parameters
array$termsArrayarray containing terms per type per language. Example: [ 'label' => [ 'en' => 'some label', 'de' => 'another label', ... ], 'alias' => [ 'en' => [ 'alias', 'another alias', ...], 'de' => 'de alias', ... ], ... ]
callable | null$callbackCalled with int[] $termInLangIds right before attempting to restore any of those acquired IDs that might have been deleted by another process before acquireTermInLangIds() has returned.
Returns
int[] List of IDs of acquired terms in the store. Due to limitations in the underlying store, in rare cases the same ID might be returned for different terms.

Implemented in Wikibase\Lib\Store\Sql\Terms\DatabaseTermInLangIdsAcquirer, and Wikibase\Lib\Store\Sql\Terms\InMemoryTermStore.


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