MediaWiki master
MediaWiki\Deferred\LinksUpdate\LinksUpdate Class Reference

Class the manages updates of *_link tables as well as similar extension-managed tables. More...

Inherits MediaWiki\Deferred\DataUpdate.

Inherited by MediaWiki\Deferred\LinksUpdate\LinksDeletionUpdate.

Collaboration diagram for MediaWiki\Deferred\LinksUpdate\LinksUpdate:

Public Member Functions

 __construct (PageIdentity $page, ParserOutput $parserOutput, $recursive=true, $maybeRedirectChanged=true)
 
 doUpdate ()
 Update link tables with outgoing links from an updated article.
 
 getAddedExternalLinks ()
 Fetch external links added by this LinksUpdate.
 
 getAddedLinks ()
 Fetch page links added by this LinksUpdate.
 
 getAddedProperties ()
 Fetch page properties added by this LinksUpdate.
 
 getImages ()
 Return the list of images used as generated by the parser.
 
 getPageId ()
 Get the page_id of the page being updated.
 
 getPageReferenceArray ( $tableName, $setType)
 Same as getPageReferenceIterator() but converted to an array for convenience (at the expense of additional time and memory usage)
 
 getPageReferenceIterator ( $tableName, $setType)
 Get an iterator over PageReferenceValue objects corresponding to a given set type in a given table.
 
 getParserOutput ()
 Returns parser output.
 
 getRemovedExternalLinks ()
 Fetch external links removed by this LinksUpdate.
 
 getRemovedLinks ()
 Fetch page links removed by this LinksUpdate.
 
 getRemovedProperties ()
 Fetch page properties removed by this LinksUpdate.
 
 getRevisionRecord ()
 
 getTitle ()
 Return the title object of the page being updated.
 
 getTriggeringUser ()
 Get the user who triggered this LinksUpdate.
 
 isRecursive ()
 Whether or not this LinksUpdate will also update pages which transclude the current page or otherwise depend on it.
 
 setMoveDetails (PageReference $oldPage)
 Notify LinksUpdate that a move has just been completed and set the original title.
 
 setRevisionRecord (RevisionRecord $revisionRecord)
 Set the RevisionRecord corresponding to this LinksUpdate.
 
 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)
 
Parameters
mixed$ticketResult of getEmptyTransactionTicket()
Since
1.28

 
 setTriggeringUser (UserIdentity $user)
 Set the user who triggered this LinksUpdate.
 
- Public Member Functions inherited from MediaWiki\Deferred\DataUpdate
 __construct ()
 
 getCauseAction ()
 
 getCauseAgent ()
 
 setCause ( $action, $user)
 

Static Public Member Functions

static acquirePageLock (IDatabase $dbw, $pageId, $why='atomicity')
 Acquire a session-level lock for performing link table updates for a page on a DB.
 
static queueRecursiveJobsForTable (PageIdentity $page, $table, $action='LinksUpdate', $userName='unknown', ?BacklinkCache $backlinkCache=null)
 Queue a RefreshLinks job for any table.
 

Protected Member Functions

 doIncrementalUpdate ()
 
 getDB ()
 
 getExternalLinksTable ()
 
 getPageLinksTable ()
 
 getPagePropsTable ()
 
 queueRecursiveJobs ()
 Queue recursive jobs for this page.
 
 updateLinksTimestamp ()
 Update links table freshness.
 

Protected Attributes

int $mId
 Page ID of the article linked from.
 
bool $mMaybeRedirectChanged
 Whether the page's redirect target may have changed in the latest revision.
 
ParserOutput $mParserOutput
 
bool $mRecursive
 Whether to queue jobs for recursive updates.
 
Title $mTitle
 Title object of the article linked from.
 
- Protected Attributes inherited from MediaWiki\Deferred\DataUpdate
string $causeAction = 'unknown'
 Short update cause action description.
 
string $causeAgent = 'unknown'
 Short update cause user description.
 
mixed $ticket
 Result from LBFactory::getEmptyTransactionTicket()
 

Detailed Description

Class the manages updates of *_link tables as well as similar extension-managed tables.

Note
LinksUpdate is managed by DeferredUpdates::execute(). Do not run this in a transaction.

See docs/deferred.txt

Definition at line 42 of file LinksUpdate.php.

Constructor & Destructor Documentation

◆ __construct()

MediaWiki\Deferred\LinksUpdate\LinksUpdate::__construct ( PageIdentity $page,
ParserOutput $parserOutput,
$recursive = true,
$maybeRedirectChanged = true )
Parameters
PageIdentity$pageThe page we're updating
ParserOutput$parserOutputOutput from a full parse of this page
bool$recursiveQueue jobs for recursive updates?
bool$maybeRedirectChangedTrue if the page's redirect target may have changed in the latest revision. If false, this is used as a hint to skip some unnecessary updates.

Definition at line 83 of file LinksUpdate.php.

References MediaWiki\MediaWikiServices\getInstance(), MediaWiki\MainConfigNames\TempCategoryCollations, and MediaWiki\MainConfigNames\UpdateRowsPerQuery.

Member Function Documentation

◆ acquirePageLock()

static MediaWiki\Deferred\LinksUpdate\LinksUpdate::acquirePageLock ( IDatabase $dbw,
$pageId,
$why = 'atomicity' )
static

Acquire a session-level lock for performing link table updates for a page on a DB.

Parameters
IDatabase$dbw
int$pageId
string$whyOne of (job, atomicity)
Since
1.27

Definition at line 194 of file LinksUpdate.php.

Referenced by MediaWiki\Deferred\LinksUpdate\LinksUpdate\doUpdate().

◆ doIncrementalUpdate()

MediaWiki\Deferred\LinksUpdate\LinksUpdate::doIncrementalUpdate ( )
protected

◆ doUpdate()

MediaWiki\Deferred\LinksUpdate\LinksUpdate::doUpdate ( )

Update link tables with outgoing links from an updated article.

Note
this is managed by DeferredUpdates::execute(). Do not run this in a transaction.

Implements MediaWiki\Deferred\DeferrableUpdate.

Definition at line 131 of file LinksUpdate.php.

References MediaWiki\Deferred\LinksUpdate\LinksUpdate\acquirePageLock(), MediaWiki\Deferred\DeferredUpdates\addUpdate(), MediaWiki\Deferred\LinksUpdate\LinksUpdate\doIncrementalUpdate(), and MediaWiki\Deferred\LinksUpdate\LinksUpdate\getDB().

◆ getAddedExternalLinks()

MediaWiki\Deferred\LinksUpdate\LinksUpdate::getAddedExternalLinks ( )

Fetch external links added by this LinksUpdate.

Only available after the update is complete.

Since
1.33
Returns
null|array Array of Strings

Definition at line 433 of file LinksUpdate.php.

◆ getAddedLinks()

MediaWiki\Deferred\LinksUpdate\LinksUpdate::getAddedLinks ( )

Fetch page links added by this LinksUpdate.

Only available after the update is complete.

Since
1.22
Deprecated
since 1.38 use getPageReferenceIterator() or getPageReferenceArray(), hard-deprecated since 1.43
Returns
Title[] Array of Titles

Definition at line 410 of file LinksUpdate.php.

References wfDeprecated().

◆ getAddedProperties()

MediaWiki\Deferred\LinksUpdate\LinksUpdate::getAddedProperties ( )

Fetch page properties added by this LinksUpdate.

Only available after the update is complete.

Since
1.28
Returns
null|array

Definition at line 453 of file LinksUpdate.php.

◆ getDB()

◆ getExternalLinksTable()

MediaWiki\Deferred\LinksUpdate\LinksUpdate::getExternalLinksTable ( )
protected

Definition at line 393 of file LinksUpdate.php.

◆ getImages()

MediaWiki\Deferred\LinksUpdate\LinksUpdate::getImages ( )

Return the list of images used as generated by the parser.

Returns
array
Deprecated
since 1.44

Definition at line 344 of file LinksUpdate.php.

References wfDeprecated().

◆ getPageId()

MediaWiki\Deferred\LinksUpdate\LinksUpdate::getPageId ( )

Get the page_id of the page being updated.

Since
1.38
Returns
int

Definition at line 322 of file LinksUpdate.php.

◆ getPageLinksTable()

MediaWiki\Deferred\LinksUpdate\LinksUpdate::getPageLinksTable ( )
protected

Definition at line 388 of file LinksUpdate.php.

◆ getPagePropsTable()

MediaWiki\Deferred\LinksUpdate\LinksUpdate::getPagePropsTable ( )
protected

Definition at line 398 of file LinksUpdate.php.

◆ getPageReferenceArray()

MediaWiki\Deferred\LinksUpdate\LinksUpdate::getPageReferenceArray ( $tableName,
$setType )

Same as getPageReferenceIterator() but converted to an array for convenience (at the expense of additional time and memory usage)

Since
1.38
Parameters
string$tableName
int$setType
Returns
PageReferenceValue[]

Definition at line 501 of file LinksUpdate.php.

◆ getPageReferenceIterator()

MediaWiki\Deferred\LinksUpdate\LinksUpdate::getPageReferenceIterator ( $tableName,
$setType )

Get an iterator over PageReferenceValue objects corresponding to a given set type in a given table.

Since
1.38
Parameters
string$tableNameThe name of any table that links to local titles
int$setTypeOne of:
  • LinksTable::INSERTED: The inserted links
  • LinksTable::DELETED: The deleted links
  • LinksTable::CHANGED: Both the inserted and deleted links
  • LinksTable::OLD: The old set of links, loaded before the update
  • LinksTable::NEW: The new set of links from the ParserOutput
Returns
iterable<PageReferenceValue>

Definition at line 482 of file LinksUpdate.php.

◆ getParserOutput()

MediaWiki\Deferred\LinksUpdate\LinksUpdate::getParserOutput ( )

Returns parser output.

Since
1.19
Returns
ParserOutput

Definition at line 335 of file LinksUpdate.php.

◆ getRemovedExternalLinks()

MediaWiki\Deferred\LinksUpdate\LinksUpdate::getRemovedExternalLinks ( )

Fetch external links removed by this LinksUpdate.

Only available after the update is complete.

Since
1.33
Returns
null|string[]

Definition at line 443 of file LinksUpdate.php.

◆ getRemovedLinks()

MediaWiki\Deferred\LinksUpdate\LinksUpdate::getRemovedLinks ( )

Fetch page links removed by this LinksUpdate.

Only available after the update is complete.

Since
1.22
Deprecated
since 1.38 use getPageReferenceIterator() or getPageReferenceArray(), hard-deprecated since 1.43
Returns
Title[] Array of Titles

Definition at line 422 of file LinksUpdate.php.

References wfDeprecated().

◆ getRemovedProperties()

MediaWiki\Deferred\LinksUpdate\LinksUpdate::getRemovedProperties ( )

Fetch page properties removed by this LinksUpdate.

Only available after the update is complete.

Since
1.28
Returns
null|array

Definition at line 463 of file LinksUpdate.php.

◆ getRevisionRecord()

MediaWiki\Deferred\LinksUpdate\LinksUpdate::getRevisionRecord ( )
Since
1.35
Returns
RevisionRecord|null

Definition at line 364 of file LinksUpdate.php.

◆ getTitle()

MediaWiki\Deferred\LinksUpdate\LinksUpdate::getTitle ( )

Return the title object of the page being updated.

Returns
Title

Definition at line 312 of file LinksUpdate.php.

◆ getTriggeringUser()

MediaWiki\Deferred\LinksUpdate\LinksUpdate::getTriggeringUser ( )

Get the user who triggered this LinksUpdate.

Since
1.27
Returns
UserIdentity|null

Definition at line 384 of file LinksUpdate.php.

◆ isRecursive()

MediaWiki\Deferred\LinksUpdate\LinksUpdate::isRecursive ( )

Whether or not this LinksUpdate will also update pages which transclude the current page or otherwise depend on it.

Returns
bool

Definition at line 537 of file LinksUpdate.php.

◆ queueRecursiveJobs()

MediaWiki\Deferred\LinksUpdate\LinksUpdate::queueRecursiveJobs ( )
protected

Queue recursive jobs for this page.

Which means do LinksUpdate on all pages that include the current page, using the job queue.

Definition at line 230 of file LinksUpdate.php.

References MediaWiki\MediaWikiServices\getInstance(), MediaWiki\JobQueue\Jobs\RefreshLinksJob\newPrioritized(), and NS_FILE.

◆ queueRecursiveJobsForTable()

static MediaWiki\Deferred\LinksUpdate\LinksUpdate::queueRecursiveJobsForTable ( PageIdentity $page,
$table,
$action = 'LinksUpdate',
$userName = 'unknown',
?BacklinkCache $backlinkCache = null )
static

Queue a RefreshLinks job for any table.

Parameters
PageIdentity$pagePage to do job for
string$tableTable to use (e.g. 'templatelinks')
string$actionTriggering action
string$userNameTriggering user name
BacklinkCache | null$backlinkCache

Definition at line 274 of file LinksUpdate.php.

References $job, MediaWiki\MediaWikiServices\getInstance(), MediaWiki\JobQueue\Job\newRootJobParams(), and wfDeprecatedMsg().

◆ setMoveDetails()

MediaWiki\Deferred\LinksUpdate\LinksUpdate::setMoveDetails ( PageReference $oldPage)

Notify LinksUpdate that a move has just been completed and set the original title.

Definition at line 122 of file LinksUpdate.php.

◆ setRevisionRecord()

MediaWiki\Deferred\LinksUpdate\LinksUpdate::setRevisionRecord ( RevisionRecord $revisionRecord)

Set the RevisionRecord corresponding to this LinksUpdate.

Since
1.35
Parameters
RevisionRecord$revisionRecord

Definition at line 355 of file LinksUpdate.php.

◆ setStrictTestMode()

MediaWiki\Deferred\LinksUpdate\LinksUpdate::setStrictTestMode ( $mode = true)

Omit conflict resolution options from the insert query so that testing can confirm that the incremental update logic was correct.

Parameters
bool$mode

Definition at line 304 of file LinksUpdate.php.

◆ setTransactionTicket()

MediaWiki\Deferred\LinksUpdate\LinksUpdate::setTransactionTicket ( $ticket)

Parameters
mixed$ticketResult of getEmptyTransactionTicket()
Since
1.28

Reimplemented from MediaWiki\Deferred\DataUpdate.

Definition at line 113 of file LinksUpdate.php.

References MediaWiki\Deferred\DataUpdate\$ticket.

◆ setTriggeringUser()

MediaWiki\Deferred\LinksUpdate\LinksUpdate::setTriggeringUser ( UserIdentity $user)

Set the user who triggered this LinksUpdate.

Since
1.27
Parameters
UserIdentity$user

Definition at line 374 of file LinksUpdate.php.

◆ updateLinksTimestamp()

MediaWiki\Deferred\LinksUpdate\LinksUpdate::updateLinksTimestamp ( )
protected

Update links table freshness.

Definition at line 508 of file LinksUpdate.php.

Member Data Documentation

◆ $mId

int MediaWiki\Deferred\LinksUpdate\LinksUpdate::$mId
protected

Page ID of the article linked from.

Definition at line 46 of file LinksUpdate.php.

Referenced by MediaWiki\Deferred\LinksUpdate\LinksDeletionUpdate\doIncrementalUpdate().

◆ $mMaybeRedirectChanged

bool MediaWiki\Deferred\LinksUpdate\LinksUpdate::$mMaybeRedirectChanged
protected

Whether the page's redirect target may have changed in the latest revision.

Definition at line 58 of file LinksUpdate.php.

◆ $mParserOutput

ParserOutput MediaWiki\Deferred\LinksUpdate\LinksUpdate::$mParserOutput
protected

Definition at line 52 of file LinksUpdate.php.

◆ $mRecursive

bool MediaWiki\Deferred\LinksUpdate\LinksUpdate::$mRecursive
protected

Whether to queue jobs for recursive updates.

Definition at line 55 of file LinksUpdate.php.

◆ $mTitle

Title MediaWiki\Deferred\LinksUpdate\LinksUpdate::$mTitle
protected

Title object of the article linked from.

Definition at line 49 of file LinksUpdate.php.

Referenced by MediaWiki\Deferred\LinksUpdate\LinksDeletionUpdate\doIncrementalUpdate().


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