Wikibase
MediaWiki Wikibase extension
Loading...
Searching...
No Matches
Wikibase\Lib\Store\Sql\Terms\DatabaseInnerTermStoreCleaner Class Reference

Cleans up the normalized term store after some terms are no longer needed. More...

+ Collaboration diagram for Wikibase\Lib\Store\Sql\Terms\DatabaseInnerTermStoreCleaner:

Public Member Functions

 __construct (LoggerInterface $logger=null)
 
 cleanTermInLangIds (IDatabase $dbw, IReadableDatabase $dbr, array $termInLangIds)
 Delete the specified wbt_term_in_lang rows from the database, as well as any wbt_text_in_lang and wbt_text rows that are now unused.
 

Private Member Functions

 cleanTextInLangIds (array $textInLangIds)
 Delete the specified wbt_text_in_lang rows from the database, as well as any text rows that are now unused.
 
 cleanTextIds (array $textIds)
 Delete the specified text rows from the database.
 
 selectFieldValuesForPrimaryKey (string $table, string $selectedVar, string $primaryKeyVar, array $primaryKeyValues, string $fname=__METHOD__)
 Select the values for a field in rows with the given primary key.
 

Private Attributes

IReadableDatabase $dbr = null
 
IDatabase $dbw = null
 
LoggerInterface $logger
 

Detailed Description

Cleans up the normalized term store after some terms are no longer needed.

Unused wbt_term_in_lang, wbt_text_in_lang and wbt_text rows are automatically removed. Unused type rows are never cleaned up.

See also
Item & Property Terms

Constructor & Destructor Documentation

◆ __construct()

Wikibase\Lib\Store\Sql\Terms\DatabaseInnerTermStoreCleaner::__construct ( LoggerInterface $logger = null)

Member Function Documentation

◆ cleanTermInLangIds()

IDatabase a connection to DB_PRIMARY Note only set on Wikibase\Lib\Store\Sql\Terms\DatabaseInnerTermStoreCleaner::cleanTermInLangIds ( IDatabase $dbw,
IReadableDatabase $dbr,
array $termInLangIds )

Delete the specified wbt_term_in_lang rows from the database, as well as any wbt_text_in_lang and wbt_text rows that are now unused.

It is the caller’s responsibility ensure that the wbt_term_in_lang rows are no longer referenced anywhere; callers will most likely want to wrap this call in a transaction for that. On the other hand, this class takes care that wbt_text_in_lang and text rows used by other wbt_term_in_lang rows are not removed.

Parameters
IDatabase$dbw
IReadableDatabase$dbr
int[]$termInLangIds(wbtl_id)

◆ cleanTextIds()

Wikibase\Lib\Store\Sql\Terms\DatabaseInnerTermStoreCleaner::cleanTextIds ( array $textIds)
private

Delete the specified text rows from the database.

Parameters
array$textIds

◆ cleanTextInLangIds()

Wikibase\Lib\Store\Sql\Terms\DatabaseInnerTermStoreCleaner::cleanTextInLangIds ( array $textInLangIds)
private

Delete the specified wbt_text_in_lang rows from the database, as well as any text rows that are now unused.

Parameters
int[]$textInLangIds

This loop checks for text ids that are currently unused, without locking the rows in the text_in_lang table.

The unused text ids found by this loop, will later be double checked for use before being locked in the text_in_lang table.

This is done to reduce the number of rows that we have to lock, while still ensuring we never remove an actually used text_id

◆ selectFieldValuesForPrimaryKey()

Wikibase\Lib\Store\Sql\Terms\DatabaseInnerTermStoreCleaner::selectFieldValuesForPrimaryKey ( string $table,
string $selectedVar,
string $primaryKeyVar,
array $primaryKeyValues,
string $fname = __METHOD__ )
private

Select the values for a field in rows with the given primary key.

All the rows with these primary keys should exist in the master database, and the selected values should never change.

This initially selects from the replica database, only falling back to the master if the replica did not return as many rows as there were specified primary key values.

Parameters
string$table
string$selectedVar
string$primaryKeyVar
int[]$primaryKeyValues
string$fname
Returns
array

Member Data Documentation

◆ $dbr

IReadableDatabase Wikibase\Lib\Store\Sql\Terms\DatabaseInnerTermStoreCleaner::$dbr = null
private

◆ $dbw

IDatabase Wikibase\Lib\Store\Sql\Terms\DatabaseInnerTermStoreCleaner::$dbw = null
private

◆ $logger

LoggerInterface Wikibase\Lib\Store\Sql\Terms\DatabaseInnerTermStoreCleaner::$logger
private

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