MediaWiki master
|
The base class for classes which update a single link table. More...
Inherited by MediaWiki\Deferred\LinksUpdate\ExternalLinksTable, MediaWiki\Deferred\LinksUpdate\InterwikiLinksTable, MediaWiki\Deferred\LinksUpdate\LangLinksTable, MediaWiki\Deferred\LinksUpdate\PagePropsTable, and MediaWiki\Deferred\LinksUpdate\TitleLinksTable.
Public Member Functions | |
beforeLock () | |
Subclasses can override this to do any necessary setup before the lock is acquired. | |
injectBaseDependencies (LBFactory $lbFactory, LinkTargetLookup $linkTargetLookup, PageIdentity $sourcePage, $batchSize) | |
This is called by the factory to inject dependencies for the base class. | |
setMoveDetails (PageReference $movedPage) | |
Notify the object that the operation is a page move, and set the original title. | |
setParserOutput (ParserOutput $parserOutput) | |
Subclasses should implement this to extract the data they need from the ParserOutput. | |
setRevision (RevisionRecord $revision) | |
Set the revision associated with the edit. | |
setStrictTestMode ( $mode=true) | |
Omit conflict resolution options from the insert query so that testing can confirm that the incremental update logic was correct. | |
setTransactionTicket ( $ticket) | |
Set the empty transaction ticket. | |
update () | |
Execute an edit/delete update. | |
Public Attributes | |
const | CHANGED = 3 |
Link type: Changed (inserted or removed) links. | |
const | DELETED = 2 |
Link type: Deleted (removed) links. | |
const | INSERTED = 1 |
Link type: Inserted (added) links. | |
const | NEW = 5 |
Link type: new links (from the ParserOutput) | |
const | OLD = 4 |
Link type: existing/old links. | |
Protected Member Functions | |
deleteLink ( $linkId) | |
Delete a link identified by ID. | |
deleteRow ( $conds) | |
Queue a deletion operation. | |
doWrites () | |
Do the common DB operations. | |
fetchExistingRows () | |
Do a select query to fetch the existing rows. | |
finishUpdate () | |
Subclasses can override this to do any updates associated with their link data, for example dispatching HTML update jobs. | |
getBatchSize () | |
Get the maximum number of rows to update in a batch. | |
getDB () | |
getExistingFields () | |
Get the fields to be used in fetchExistingRows(). | |
getExistingLinkIDs () | |
Get an array (or iterator) of link IDs for the existing state. | |
getFromConds () | |
Get field=>value associative array for the from field(s) | |
getFromField () | |
Get the name of the field which links to page_id. | |
getInsertOptions () | |
Get the options for the insert queries. | |
getLBFactory () | |
getLinkIDs ( $setType) | |
Get an array or iterator of link IDs of a given type. | |
getMovedPage () | |
Assuming the page was moved, get the original page title before the move. | |
getNewLinkIDs () | |
Get an array (or iterator) of link IDs for the new state. | |
getRevision () | |
Get the RevisionRecord of the new revision, if the LinksUpdate caller injected one. | |
getSourcePage () | |
Get the source page, i.e. | |
getSourcePageId () | |
Get the page_id of the source page. | |
getTableName () | |
Get the table name. | |
getTransactionTicket () | |
Get the empty transaction ticket, or null if there is none. | |
insertLink ( $linkId) | |
Insert a link identified by ID. | |
insertRow ( $row) | |
Queue a row for insertion. | |
isCrossNamespaceMove () | |
Determine whether the page was moved to a different namespace. | |
isExisting ( $linkId) | |
Determine whether a link (from the new set) is in the existing set. | |
isInNewSet ( $linkId) | |
Determine whether a link (from the existing set) is in the new set. | |
isMove () | |
Determine whether the page was moved. | |
linksTargetNormalizationStage () | |
Normalization stage of the links table (see T222224) | |
needForcedLinkRefresh () | |
Subclasses can override this to return true in order to force reinsertion of all the links due to some property of the link changing for reasons not represented by the link ID. | |
startUpdate () | |
Subclasses can override this to do any necessary setup before individual write operations begin. | |
Protected Attributes | |
array | $deletedLinks = [] |
Link IDs for deleted links. | |
array | $insertedLinks = [] |
Link IDs for inserted links. | |
LinkTargetLookup | $linkTargetLookup |
array | $rowsToDelete = [] |
Rows to delete. | |
array | $rowsToInsert = [] |
Rows to insert. | |
bool | $strictTestMode |
The base class for classes which update a single link table.
A LinksTable object is a container for new and existing link sets outbound from a single page, and an abstraction of the associated DB schema. The object stores state related to an update of the outbound links of a page.
Link IDs identify a link in the new or old state, or in the change arrays. They are opaque to the base class and are type-hinted here as mixed.
Conventionally, the link ID is string|string[] and contains the link target fields.
The link ID should contain enough information so that the base class can tell whether an existing link is in the new set, or vice versa, for the purposes of incremental updates. If a change to a field would cause a DB update, the field should be in the link ID.
For example, a change to cl_timestamp does not trigger an update, so cl_timestamp is not in the link ID.
Definition at line 42 of file LinksTable.php.
MediaWiki\Deferred\LinksUpdate\LinksTable::beforeLock | ( | ) |
Subclasses can override this to do any necessary setup before the lock is acquired.
Definition at line 429 of file LinksTable.php.
|
abstractprotected |
Delete a link identified by ID.
The subclass is expected to queue the deletion by calling deleteRow().
mixed | $linkId |
Reimplemented in MediaWiki\Deferred\LinksUpdate\CategoryLinksTable, MediaWiki\Deferred\LinksUpdate\ExternalLinksTable, MediaWiki\Deferred\LinksUpdate\GenericPageLinksTable, MediaWiki\Deferred\LinksUpdate\ImageLinksTable, MediaWiki\Deferred\LinksUpdate\InterwikiLinksTable, MediaWiki\Deferred\LinksUpdate\LangLinksTable, and MediaWiki\Deferred\LinksUpdate\PagePropsTable.
|
protected |
Queue a deletion operation.
Subclasses are expected to call this from deleteLink(). The "from" field does not need to be included in the conditions.
Most often, the conditions match a single row, but this is not required.
array | $conds | Associative array mapping fields to values, specifying the conditions for a delete query. |
Definition at line 417 of file LinksTable.php.
Referenced by MediaWiki\Deferred\LinksUpdate\CategoryLinksTable\deleteLink(), MediaWiki\Deferred\LinksUpdate\ExternalLinksTable\deleteLink(), MediaWiki\Deferred\LinksUpdate\ImageLinksTable\deleteLink(), MediaWiki\Deferred\LinksUpdate\InterwikiLinksTable\deleteLink(), MediaWiki\Deferred\LinksUpdate\LangLinksTable\deleteLink(), and MediaWiki\Deferred\LinksUpdate\PagePropsTable\deleteLink().
|
protected |
Do the common DB operations.
Definition at line 453 of file LinksTable.php.
References Wikimedia\Rdbms\Platform\ISQLPlatform\factorConds(), Wikimedia\Rdbms\IReadableDatabase\getDomainID(), Wikimedia\Rdbms\IDatabase\newDeleteQueryBuilder(), and Wikimedia\Rdbms\IDatabase\newInsertQueryBuilder().
|
protected |
Do a select query to fetch the existing rows.
This is a helper for subclasses.
Reimplemented in MediaWiki\Deferred\LinksUpdate\GenericPageLinksTable.
Definition at line 364 of file LinksTable.php.
|
protected |
Subclasses can override this to do any updates associated with their link data, for example dispatching HTML update jobs.
Reimplemented in MediaWiki\Deferred\LinksUpdate\CategoryLinksTable, MediaWiki\Deferred\LinksUpdate\ImageLinksTable, and MediaWiki\Deferred\LinksUpdate\PagePropsTable.
Definition at line 447 of file LinksTable.php.
|
protected |
Get the maximum number of rows to update in a batch.
Definition at line 325 of file LinksTable.php.
|
protected |
Definition at line 261 of file LinksTable.php.
Referenced by MediaWiki\Deferred\LinksUpdate\CategoryLinksTable\insertLink().
|
abstractprotected |
Get the fields to be used in fetchExistingRows().
Note that fetchExistingRows() is just a helper for subclasses. The value returned here is effectively private to the subclass.
Reimplemented in MediaWiki\Deferred\LinksUpdate\CategoryLinksTable, MediaWiki\Deferred\LinksUpdate\ExternalLinksTable, MediaWiki\Deferred\LinksUpdate\GenericPageLinksTable, MediaWiki\Deferred\LinksUpdate\ImageLinksTable, MediaWiki\Deferred\LinksUpdate\InterwikiLinksTable, MediaWiki\Deferred\LinksUpdate\LangLinksTable, and MediaWiki\Deferred\LinksUpdate\PagePropsTable.
|
abstractprotected |
Get an array (or iterator) of link IDs for the existing state.
The subclass should load the data from the database. There is fetchExistingRows() to make this easier but the subclass is responsible for caching.
See the LinksTable doc comment for an explanation of link IDs.
Reimplemented in MediaWiki\Deferred\LinksUpdate\CategoryLinksTable, MediaWiki\Deferred\LinksUpdate\ExternalLinksTable, MediaWiki\Deferred\LinksUpdate\GenericPageLinksTable, MediaWiki\Deferred\LinksUpdate\ImageLinksTable, MediaWiki\Deferred\LinksUpdate\InterwikiLinksTable, MediaWiki\Deferred\LinksUpdate\LangLinksTable, and MediaWiki\Deferred\LinksUpdate\PagePropsTable.
|
protected |
Get field=>value associative array for the from field(s)
Definition at line 354 of file LinksTable.php.
|
abstractprotected |
Get the name of the field which links to page_id.
Reimplemented in MediaWiki\Deferred\LinksUpdate\CategoryLinksTable, MediaWiki\Deferred\LinksUpdate\ExternalLinksTable, MediaWiki\Deferred\LinksUpdate\ImageLinksTable, MediaWiki\Deferred\LinksUpdate\InterwikiLinksTable, MediaWiki\Deferred\LinksUpdate\LangLinksTable, MediaWiki\Deferred\LinksUpdate\PageLinksTable, MediaWiki\Deferred\LinksUpdate\PagePropsTable, and MediaWiki\Deferred\LinksUpdate\TemplateLinksTable.
|
protected |
|
protected |
Definition at line 268 of file LinksTable.php.
|
protected |
Get an array or iterator of link IDs of a given type.
Some subclasses use this to provide typed data to callers. This is not public because link IDs are a private concept.
int | $setType | One of the class constants: self::INSERTED, self::DELETED, self::CHANGED, self::OLD or self::NEW. |
Definition at line 516 of file LinksTable.php.
Referenced by MediaWiki\Deferred\LinksUpdate\PagePropsTable\getAssocArray(), and MediaWiki\Deferred\LinksUpdate\ExternalLinksTable\getStringArray().
|
protected |
Assuming the page was moved, get the original page title before the move.
This will throw an exception if the page wasn't moved.
Definition at line 316 of file LinksTable.php.
|
abstractprotected |
Get an array (or iterator) of link IDs for the new state.
See the LinksTable doc comment for an explanation of link IDs.
Reimplemented in MediaWiki\Deferred\LinksUpdate\CategoryLinksTable, MediaWiki\Deferred\LinksUpdate\ExternalLinksTable, MediaWiki\Deferred\LinksUpdate\GenericPageLinksTable, MediaWiki\Deferred\LinksUpdate\ImageLinksTable, MediaWiki\Deferred\LinksUpdate\InterwikiLinksTable, MediaWiki\Deferred\LinksUpdate\LangLinksTable, and MediaWiki\Deferred\LinksUpdate\PagePropsTable.
|
protected |
Get the RevisionRecord of the new revision, if the LinksUpdate caller injected one.
Definition at line 344 of file LinksTable.php.
|
protected |
Get the source page, i.e.
the page which is being updated and is the source of links.
Definition at line 287 of file LinksTable.php.
Referenced by MediaWiki\Deferred\LinksUpdate\ImageLinksTable\insertLink(), MediaWiki\Deferred\LinksUpdate\CategoryLinksTable\setParserOutput(), and MediaWiki\Deferred\LinksUpdate\CategoryLinksTable\startUpdate().
|
protected |
|
abstractprotected |
Get the table name.
Reimplemented in MediaWiki\Deferred\LinksUpdate\CategoryLinksTable, MediaWiki\Deferred\LinksUpdate\ExternalLinksTable, MediaWiki\Deferred\LinksUpdate\ImageLinksTable, MediaWiki\Deferred\LinksUpdate\InterwikiLinksTable, MediaWiki\Deferred\LinksUpdate\LangLinksTable, MediaWiki\Deferred\LinksUpdate\PageLinksTable, MediaWiki\Deferred\LinksUpdate\PagePropsTable, and MediaWiki\Deferred\LinksUpdate\TemplateLinksTable.
|
protected |
Get the empty transaction ticket, or null if there is none.
Definition at line 334 of file LinksTable.php.
|
final |
This is called by the factory to inject dependencies for the base class.
This is used instead of the constructor so that changes can be made to the injected parameters without breaking the subclass constructors.
LBFactory | $lbFactory | |
LinkTargetLookup | $linkTargetLookup | |
PageIdentity | $sourcePage | |
int | $batchSize |
Definition at line 118 of file LinksTable.php.
References MediaWiki\Deferred\LinksUpdate\LinksTable\$linkTargetLookup, and Wikimedia\Rdbms\LBFactory\getPrimaryDatabase().
|
abstractprotected |
Insert a link identified by ID.
The subclass is expected to queue the insertion by calling insertRow().
mixed | $linkId |
Reimplemented in MediaWiki\Deferred\LinksUpdate\CategoryLinksTable, MediaWiki\Deferred\LinksUpdate\ExternalLinksTable, MediaWiki\Deferred\LinksUpdate\GenericPageLinksTable, MediaWiki\Deferred\LinksUpdate\ImageLinksTable, MediaWiki\Deferred\LinksUpdate\InterwikiLinksTable, MediaWiki\Deferred\LinksUpdate\LangLinksTable, and MediaWiki\Deferred\LinksUpdate\PagePropsTable.
|
protected |
Queue a row for insertion.
Subclasses are expected to call this from insertLink(). The "from" field should not be included in the row.
array | $row | Associative array mapping fields to values. |
Definition at line 402 of file LinksTable.php.
Referenced by MediaWiki\Deferred\LinksUpdate\CategoryLinksTable\insertLink(), MediaWiki\Deferred\LinksUpdate\ExternalLinksTable\insertLink(), MediaWiki\Deferred\LinksUpdate\ImageLinksTable\insertLink(), MediaWiki\Deferred\LinksUpdate\InterwikiLinksTable\insertLink(), MediaWiki\Deferred\LinksUpdate\LangLinksTable\insertLink(), and MediaWiki\Deferred\LinksUpdate\PagePropsTable\insertLink().
|
protected |
Determine whether the page was moved to a different namespace.
Definition at line 305 of file LinksTable.php.
Referenced by MediaWiki\Deferred\LinksUpdate\ImageLinksTable\needForcedLinkRefresh().
|
abstractprotected |
Determine whether a link (from the new set) is in the existing set.
mixed | $linkId |
Reimplemented in MediaWiki\Deferred\LinksUpdate\CategoryLinksTable, MediaWiki\Deferred\LinksUpdate\ExternalLinksTable, MediaWiki\Deferred\LinksUpdate\GenericPageLinksTable, MediaWiki\Deferred\LinksUpdate\ImageLinksTable, MediaWiki\Deferred\LinksUpdate\InterwikiLinksTable, MediaWiki\Deferred\LinksUpdate\LangLinksTable, and MediaWiki\Deferred\LinksUpdate\PagePropsTable.
|
abstractprotected |
Determine whether a link (from the existing set) is in the new set.
mixed | $linkId |
Reimplemented in MediaWiki\Deferred\LinksUpdate\CategoryLinksTable, MediaWiki\Deferred\LinksUpdate\ExternalLinksTable, MediaWiki\Deferred\LinksUpdate\GenericPageLinksTable, MediaWiki\Deferred\LinksUpdate\ImageLinksTable, MediaWiki\Deferred\LinksUpdate\InterwikiLinksTable, MediaWiki\Deferred\LinksUpdate\LangLinksTable, and MediaWiki\Deferred\LinksUpdate\PagePropsTable.
|
protected |
Determine whether the page was moved.
Definition at line 296 of file LinksTable.php.
Referenced by MediaWiki\Deferred\LinksUpdate\CategoryLinksTable\needForcedLinkRefresh().
|
protected |
Normalization stage of the links table (see T222224)
Reimplemented in MediaWiki\Deferred\LinksUpdate\PageLinksTable, and MediaWiki\Deferred\LinksUpdate\TemplateLinksTable.
Definition at line 542 of file LinksTable.php.
Referenced by MediaWiki\Deferred\LinksUpdate\GenericPageLinksTable\getExistingFields().
|
protected |
Subclasses can override this to return true in order to force reinsertion of all the links due to some property of the link changing for reasons not represented by the link ID.
Reimplemented in MediaWiki\Deferred\LinksUpdate\CategoryLinksTable, MediaWiki\Deferred\LinksUpdate\GenericPageLinksTable, and MediaWiki\Deferred\LinksUpdate\ImageLinksTable.
Definition at line 253 of file LinksTable.php.
MediaWiki\Deferred\LinksUpdate\LinksTable::setMoveDetails | ( | PageReference | $movedPage | ) |
Notify the object that the operation is a page move, and set the original title.
PageReference | $movedPage |
Definition at line 155 of file LinksTable.php.
|
abstract |
Subclasses should implement this to extract the data they need from the ParserOutput.
To support a future refactor of LinksDeletionUpdate, if this method is not called, the subclass should assume that the new state is empty.
ParserOutput | $parserOutput |
Reimplemented in MediaWiki\Deferred\LinksUpdate\CategoryLinksTable, MediaWiki\Deferred\LinksUpdate\ExternalLinksTable, MediaWiki\Deferred\LinksUpdate\ImageLinksTable, MediaWiki\Deferred\LinksUpdate\InterwikiLinksTable, MediaWiki\Deferred\LinksUpdate\LangLinksTable, MediaWiki\Deferred\LinksUpdate\PageLinksTable, MediaWiki\Deferred\LinksUpdate\PagePropsTable, and MediaWiki\Deferred\LinksUpdate\TemplateLinksTable.
MediaWiki\Deferred\LinksUpdate\LinksTable::setRevision | ( | RevisionRecord | $revision | ) |
Set the revision associated with the edit.
RevisionRecord | $revision |
Definition at line 145 of file LinksTable.php.
MediaWiki\Deferred\LinksUpdate\LinksTable::setStrictTestMode | ( | $mode = true | ) |
Omit conflict resolution options from the insert query so that testing can confirm that the incremental update logic was correct.
bool | $mode |
Definition at line 490 of file LinksTable.php.
MediaWiki\Deferred\LinksUpdate\LinksTable::setTransactionTicket | ( | $ticket | ) |
Set the empty transaction ticket.
mixed | $ticket |
Definition at line 136 of file LinksTable.php.
|
protected |
Subclasses can override this to do any necessary setup before individual write operations begin.
Reimplemented in MediaWiki\Deferred\LinksUpdate\CategoryLinksTable.
Definition at line 438 of file LinksTable.php.
|
final |
Execute an edit/delete update.
Definition at line 376 of file LinksTable.php.
|
protected |
Link IDs for deleted links.
Definition at line 79 of file LinksTable.php.
|
protected |
Link IDs for inserted links.
Definition at line 76 of file LinksTable.php.
|
protected |
Definition at line 85 of file LinksTable.php.
Referenced by MediaWiki\Deferred\LinksUpdate\LinksTable\injectBaseDependencies().
|
protected |
Rows to delete.
An array of associative arrays, each associative array being the conditions for a delete query. Common conditions should be leftmost in the associative array so that they can be factored out.
Definition at line 65 of file LinksTable.php.
|
protected |
Rows to insert.
An array of associative arrays, each associative array mapping field names to values.
Definition at line 73 of file LinksTable.php.
|
protected |
Definition at line 106 of file LinksTable.php.
const MediaWiki\Deferred\LinksUpdate\LinksTable::CHANGED = 3 |
Link type: Changed (inserted or removed) links.
Definition at line 50 of file LinksTable.php.
const MediaWiki\Deferred\LinksUpdate\LinksTable::DELETED = 2 |
Link type: Deleted (removed) links.
Definition at line 47 of file LinksTable.php.
const MediaWiki\Deferred\LinksUpdate\LinksTable::INSERTED = 1 |
Link type: Inserted (added) links.
Definition at line 44 of file LinksTable.php.
const MediaWiki\Deferred\LinksUpdate\LinksTable::NEW = 5 |
Link type: new links (from the ParserOutput)
Definition at line 56 of file LinksTable.php.
const MediaWiki\Deferred\LinksUpdate\LinksTable::OLD = 4 |
Link type: existing/old links.
Definition at line 53 of file LinksTable.php.