MediaWiki  1.23.2
LinksUpdate Class Reference

See docs/deferred.txt. More...

Inheritance diagram for LinksUpdate:
Collaboration diagram for LinksUpdate:

Public Member Functions

 __construct ( $title, $parserOutput, $recursive=true)
 Constructor. More...
 
 doUpdate ()
 Update link tables with outgoing links from an updated article. More...
 
 getAddedLinks ()
 Fetch page links added by this LinksUpdate. More...
 
 getImages ()
 Return the list of images used as generated by the parser. More...
 
 getParserOutput ()
 Returns parser output. More...
 
 getPropertyDeletions ( $existing)
 Get array of properties which should be deleted. More...
 
 getPropertyInsertions ( $existing=array())
 Get an array of page property insertions. More...
 
 getRemovedLinks ()
 Fetch page links removed by this LinksUpdate. More...
 
 getTitle ()
 Return the title object of the page being updated. More...
 
 incrTableUpdate ( $table, $prefix, $deletions, $insertions)
 Update a table by doing a delete query then an insert query. More...
 
 invalidateCategories ( $cats)
 
 invalidateImageDescriptions ( $images)
 
 queueRecursiveJobs ()
 Queue recursive jobs for this page. More...
 
 updateCategoryCounts ( $added, $deleted)
 Update all the appropriate counts in the category table. More...
 
- Public Member Functions inherited from SqlDataUpdate
 __construct ( $withTransaction=true)
 Constructor. More...
 
 abortTransaction ()
 Abort the database transaction started via beginTransaction (if any). More...
 
 beginTransaction ()
 Begin a database transaction, if $withTransaction was given as true in the constructor for this SqlDataUpdate. More...
 
 commitTransaction ()
 Commit the database transaction started via beginTransaction (if any). More...
 
- Public Member Functions inherited from DataUpdate
 __construct ()
 Constructor. More...
 
 rollbackTransaction ()
 Abort / roll back the transaction started via beginTransaction, if any. More...
 

Static Public Member Functions

static queueRecursiveJobsForTable (Title $title, $table)
 Queue a RefreshLinks job for any table. More...
 
- Static Public Member Functions inherited from DataUpdate
static runUpdates ( $updates)
 Convenience method, calls doUpdate() on every DataUpdate in the array. More...
 

Public Attributes

array $mCategories
 Map of category names to sort keys *. More...
 
DatabaseBase $mDb
 Database connection reference *. More...
 
array $mExternals
 URLs of external links, array key only *. More...
 
int $mId
 Page ID of the article linked from *. More...
 
array $mImages
 DB keys of the images used, in the array key only *. More...
 
array $mInterlangs
 ap of language codes to titles * More...
 
array $mLinks
 Map of title strings to IDs for the links in the document *. More...
 
array $mOptions
 SELECT options to be used *. More...
 
ParserOutput $mParserOutput
 
array $mProperties
 Map of arbitrary name to value *. More...
 
bool $mRecursive
 Whether to queue jobs for recursive updates *. More...
 
array $mTemplates
 Map of title strings to IDs for the template references, including broken ones *. More...
 
Title $mTitle
 object of the article linked from * More...
 

Protected Member Functions

 doIncrementalUpdate ()
 
 getExistingInterwikis ()
 Get an array of existing inline interwiki links, as a 2-D array. More...
 
 updateLinksTimestamp ()
 Update links table freshness. More...
 
- Protected Member Functions inherited from SqlDataUpdate
 invalidatePages ( $namespace, array $dbkeys)
 Invalidate the cache of a list of pages from a single namespace. More...
 

Private Member Functions

 getCategoryDeletions ( $existing)
 Given an array of existing categories, returns those categories which are not in $this and thus should be deleted. More...
 
 getCategoryInsertions ( $existing=array())
 Get an array of category insertions. More...
 
 getExistingCategories ()
 Get an array of existing categories, with the name in the key and sort key in the value. More...
 
 getExistingExternals ()
 Get an array of existing external links, URLs in the keys. More...
 
 getExistingImages ()
 Get an array of existing images, image names in the keys. More...
 
 getExistingInterlangs ()
 Get an array of existing interlanguage links, with the language code in the key and the title in the value. More...
 
 getExistingLinks ()
 Get an array of existing links, as a 2-D array. More...
 
 getExistingProperties ()
 Get an array of existing categories, with the name in the key and sort key in the value. More...
 
 getExistingTemplates ()
 Get an array of existing templates, as a 2-D array. More...
 
 getExternalDeletions ( $existing)
 Given an array of existing external links, returns those links which are not in $this and thus should be deleted. More...
 
 getExternalInsertions ( $existing=array())
 Get an array of externallinks insertions. More...
 
 getImageDeletions ( $existing)
 Given an array of existing images, returns those images which are not in $this and thus should be deleted. More...
 
 getImageInsertions ( $existing=array())
 Get an array of image insertions Skips the names specified in $existing. More...
 
 getInterlangDeletions ( $existing)
 Given an array of existing interlanguage links, returns those links which are not in $this and thus should be deleted. More...
 
 getInterlangInsertions ( $existing=array())
 Get an array of interlanguage link insertions. More...
 
 getInterwikiDeletions ( $existing)
 Given an array of existing interwiki links, returns those links which are not in $this and thus should be deleted. More...
 
 getInterwikiInsertions ( $existing=array())
 Get an array of interwiki insertions for passing to the DB Skips the titles specified by the 2-D array $existing. More...
 
 getLinkDeletions ( $existing)
 Given an array of existing links, returns those links which are not in $this and thus should be deleted. More...
 
 getLinkInsertions ( $existing=array())
 Get an array of pagelinks insertions for passing to the DB Skips the titles specified by the 2-D array $existing. More...
 
 getTemplateDeletions ( $existing)
 Given an array of existing templates, returns those templates which are not in $this and thus should be deleted. More...
 
 getTemplateInsertions ( $existing=array())
 Get an array of template insertions. More...
 
 invalidateProperties ( $changed)
 Invalidate any necessary link lists related to page property changes. More...
 

Private Attributes

null array $linkDeletions = null
 Deleted links if calculated. More...
 
null array $linkInsertions = null
 Added links if calculated. More...
 

Additional Inherited Members

- Protected Attributes inherited from SqlDataUpdate
DatabaseBase $mDb
 Database connection reference *. More...
 
array $mOptions
 SELECT options to be used (array) *. More...
 
bool $mUseTransaction
 Whether this update should be wrapped in a transaction *. More...
 

Detailed Description

See docs/deferred.txt.

Todo:
document (e.g. one-sentence top-level class description).

Definition at line 28 of file LinksUpdate.php.

Constructor & Destructor Documentation

◆ __construct()

LinksUpdate::__construct (   $title,
  $parserOutput,
  $recursive = true 
)

Constructor.

Parameters
Title$titleTitle of the page we're updating
ParserOutput$parserOutputOutput from a full parse of this page
bool$recursiveQueue jobs for recursive updates?
Exceptions
MWException

Definition at line 73 of file LinksUpdate.php.

References $link, $title, array(), as, list, and wfRunHooks().

Member Function Documentation

◆ doIncrementalUpdate()

◆ doUpdate()

LinksUpdate::doUpdate ( )

Update link tables with outgoing links from an updated article.

Implements DeferrableUpdate.

Definition at line 134 of file LinksUpdate.php.

References array(), doIncrementalUpdate(), and wfRunHooks().

◆ getAddedLinks()

LinksUpdate::getAddedLinks ( )

Fetch page links added by this LinksUpdate.

Only available after the update is complete.

Since
1.22
Returns
null|array of Titles

Definition at line 821 of file LinksUpdate.php.

References array(), as, and Title\makeTitle().

◆ getCategoryDeletions()

LinksUpdate::getCategoryDeletions (   $existing)
private

Given an array of existing categories, returns those categories which are not in $this and thus should be deleted.

Parameters
array$existing
Returns
array

Definition at line 591 of file LinksUpdate.php.

Referenced by doIncrementalUpdate().

◆ getCategoryInsertions()

LinksUpdate::getCategoryInsertions (   $existing = array())
private

Get an array of category insertions.

Parameters
array$existingmapping existing category names to sort keys. If both match a link in $this, the link will be omitted from the output
Returns
array

Definition at line 425 of file LinksUpdate.php.

References $name, $type, $wgContLang, array(), as, global, Title\makeTitleSafe(), NS_CATEGORY, NS_FILE, and Collation\singleton().

Referenced by doIncrementalUpdate().

◆ getExistingCategories()

LinksUpdate::getExistingCategories ( )
private

Get an array of existing categories, with the name in the key and sort key in the value.

Returns
array

Definition at line 708 of file LinksUpdate.php.

References $res, array(), and as.

Referenced by doIncrementalUpdate().

◆ getExistingExternals()

LinksUpdate::getExistingExternals ( )
private

Get an array of existing external links, URLs in the keys.

Returns
array

Definition at line 692 of file LinksUpdate.php.

References $res, array(), and as.

Referenced by doIncrementalUpdate().

◆ getExistingImages()

LinksUpdate::getExistingImages ( )
private

Get an array of existing images, image names in the keys.

Returns
array

Definition at line 676 of file LinksUpdate.php.

References $res, array(), and as.

Referenced by doIncrementalUpdate().

◆ getExistingInterlangs()

LinksUpdate::getExistingInterlangs ( )
private

Get an array of existing interlanguage links, with the language code in the key and the title in the value.

Returns
array

Definition at line 725 of file LinksUpdate.php.

References $res, array(), and as.

Referenced by doIncrementalUpdate().

◆ getExistingInterwikis()

LinksUpdate::getExistingInterwikis ( )
protected

Get an array of existing inline interwiki links, as a 2-D array.

Returns
array (prefix => array(dbkey => 1))

Definition at line 740 of file LinksUpdate.php.

References $res, array(), and as.

Referenced by doIncrementalUpdate().

◆ getExistingLinks()

LinksUpdate::getExistingLinks ( )
private

Get an array of existing links, as a 2-D array.

Returns
array

Definition at line 638 of file LinksUpdate.php.

References $res, array(), and as.

Referenced by doIncrementalUpdate().

◆ getExistingProperties()

LinksUpdate::getExistingProperties ( )
private

Get an array of existing categories, with the name in the key and sort key in the value.

Returns
array of property names and values

Definition at line 759 of file LinksUpdate.php.

References $res, array(), and as.

Referenced by doIncrementalUpdate().

◆ getExistingTemplates()

LinksUpdate::getExistingTemplates ( )
private

Get an array of existing templates, as a 2-D array.

Returns
array

Definition at line 657 of file LinksUpdate.php.

References $res, array(), and as.

Referenced by doIncrementalUpdate().

◆ getExternalDeletions()

LinksUpdate::getExternalDeletions (   $existing)
private

Given an array of existing external links, returns those links which are not in $this and thus should be deleted.

Parameters
array$existing
Returns
array

Definition at line 581 of file LinksUpdate.php.

Referenced by doIncrementalUpdate().

◆ getExternalInsertions()

LinksUpdate::getExternalInsertions (   $existing = array())
private

Get an array of externallinks insertions.

Skips the names specified in $existing

Parameters
array$existing
Returns
array

Definition at line 400 of file LinksUpdate.php.

References $mId, array(), as, and wfMakeUrlIndexes().

Referenced by doIncrementalUpdate().

◆ getImageDeletions()

LinksUpdate::getImageDeletions (   $existing)
private

Given an array of existing images, returns those images which are not in $this and thus should be deleted.

Parameters
array$existing
Returns
array

Definition at line 571 of file LinksUpdate.php.

Referenced by doIncrementalUpdate().

◆ getImageInsertions()

LinksUpdate::getImageInsertions (   $existing = array())
private

Get an array of image insertions Skips the names specified in $existing.

Parameters
array$existing
Returns
array

Definition at line 382 of file LinksUpdate.php.

References array(), and as.

Referenced by doIncrementalUpdate().

◆ getImages()

LinksUpdate::getImages ( )

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

Returns
array

Definition at line 791 of file LinksUpdate.php.

References $mImages.

◆ getInterlangDeletions()

LinksUpdate::getInterlangDeletions (   $existing)
private

Given an array of existing interlanguage links, returns those links which are not in $this and thus should be deleted.

Parameters
array$existing
Returns
array

Definition at line 601 of file LinksUpdate.php.

Referenced by doIncrementalUpdate().

◆ getInterlangInsertions()

LinksUpdate::getInterlangInsertions (   $existing = array())
private

Get an array of interlanguage link insertions.

Parameters
array$existingmapping existing language codes to titles
Returns
array

Definition at line 469 of file LinksUpdate.php.

References $title, array(), and as.

Referenced by doIncrementalUpdate().

◆ getInterwikiDeletions()

LinksUpdate::getInterwikiDeletions (   $existing)
private

Given an array of existing interwiki links, returns those links which are not in $this and thus should be deleted.

Parameters
array$existing
Returns
array

Definition at line 620 of file LinksUpdate.php.

References array(), and as.

Referenced by doIncrementalUpdate().

◆ getInterwikiInsertions()

LinksUpdate::getInterwikiInsertions (   $existing = array())
private

Get an array of interwiki insertions for passing to the DB Skips the titles specified by the 2-D array $existing.

Parameters
array$existing
Returns
array

Definition at line 508 of file LinksUpdate.php.

References array(), and as.

Referenced by doIncrementalUpdate().

◆ getLinkDeletions()

LinksUpdate::getLinkDeletions (   $existing)
private

Given an array of existing links, returns those links which are not in $this and thus should be deleted.

Parameters
array$existing
Returns
array

Definition at line 533 of file LinksUpdate.php.

References array(), and as.

Referenced by doIncrementalUpdate().

◆ getLinkInsertions()

LinksUpdate::getLinkInsertions (   $existing = array())
private

Get an array of pagelinks insertions for passing to the DB Skips the titles specified by the 2-D array $existing.

Parameters
array$existing
Returns
array

Definition at line 337 of file LinksUpdate.php.

References array(), and as.

Referenced by doIncrementalUpdate().

◆ getParserOutput()

LinksUpdate::getParserOutput ( )

Returns parser output.

Since
1.19
Returns
ParserOutput

Definition at line 783 of file LinksUpdate.php.

References $mParserOutput.

◆ getPropertyDeletions()

LinksUpdate::getPropertyDeletions (   $existing)

Get array of properties which should be deleted.

Parameters
array$existing
Returns
array

Definition at line 610 of file LinksUpdate.php.

Referenced by doIncrementalUpdate().

◆ getPropertyInsertions()

LinksUpdate::getPropertyInsertions (   $existing = array())

Get an array of page property insertions.

Parameters
array$existing
Returns
array

Definition at line 488 of file LinksUpdate.php.

References $name, $value, array(), and as.

Referenced by doIncrementalUpdate().

◆ getRemovedLinks()

LinksUpdate::getRemovedLinks ( )

Fetch page links removed by this LinksUpdate.

Only available after the update is complete.

Since
1.22
Returns
null|array of Titles

Definition at line 838 of file LinksUpdate.php.

References $title, $titles, array(), as, and Title\makeTitle().

◆ getTemplateDeletions()

LinksUpdate::getTemplateDeletions (   $existing)
private

Given an array of existing templates, returns those templates which are not in $this and thus should be deleted.

Parameters
array$existing
Returns
array

Definition at line 552 of file LinksUpdate.php.

References array(), and as.

Referenced by doIncrementalUpdate().

◆ getTemplateInsertions()

LinksUpdate::getTemplateInsertions (   $existing = array())
private

Get an array of template insertions.

Like getLinkInsertions()

Parameters
array$existing
Returns
array

Definition at line 360 of file LinksUpdate.php.

References array(), and as.

Referenced by doIncrementalUpdate().

◆ getTitle()

LinksUpdate::getTitle ( )

Return the title object of the page being updated.

Returns
Title

Definition at line 774 of file LinksUpdate.php.

References $mTitle.

◆ incrTableUpdate()

LinksUpdate::incrTableUpdate (   $table,
  $prefix,
  $deletions,
  $insertions 
)

Update a table by doing a delete query then an insert query.

Parameters
string$tableTable name
string$prefixField name prefix
array$deletions
array$insertionsRows to insert

Definition at line 289 of file LinksUpdate.php.

References array(), and wfRunHooks().

Referenced by doIncrementalUpdate().

◆ invalidateCategories()

LinksUpdate::invalidateCategories (   $cats)
Parameters
$cats

Definition at line 259 of file LinksUpdate.php.

References SqlDataUpdate\invalidatePages(), and NS_CATEGORY.

Referenced by doIncrementalUpdate().

◆ invalidateImageDescriptions()

LinksUpdate::invalidateImageDescriptions (   $images)
Parameters
$images

Definition at line 278 of file LinksUpdate.php.

References SqlDataUpdate\invalidatePages(), and NS_FILE.

Referenced by doIncrementalUpdate().

◆ invalidateProperties()

LinksUpdate::invalidateProperties (   $changed)
private

Invalidate any necessary link lists related to page property changes.

Parameters
array$changed

Definition at line 799 of file LinksUpdate.php.

References $changed, $name, $value, array(), as, and global.

Referenced by doIncrementalUpdate().

◆ queueRecursiveJobs()

LinksUpdate::queueRecursiveJobs ( )

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 224 of file LinksUpdate.php.

References NS_FILE, and queueRecursiveJobsForTable().

Referenced by doIncrementalUpdate().

◆ queueRecursiveJobsForTable()

static LinksUpdate::queueRecursiveJobsForTable ( Title  $title,
  $table 
)
static

Queue a RefreshLinks job for any table.

Parameters
Title$titleTitle to do job for
string$tableTable to use (e.g. 'templatelinks')

Definition at line 238 of file LinksUpdate.php.

References $job, $title, array(), Job\newRootJobParams(), JobQueueGroup\singleton(), wfProfileIn(), and wfProfileOut().

Referenced by WikiPage\doDeleteUpdates(), queueRecursiveJobs(), and LocalFile\recordUpload2().

◆ updateCategoryCounts()

LinksUpdate::updateCategoryCounts (   $added,
  $deleted 
)

Update all the appropriate counts in the category table.

Parameters
array$addedAssociative array of category name => sort key
array$deletedAssociative array of category name => sort key

Definition at line 268 of file LinksUpdate.php.

References WikiPage\factory().

Referenced by doIncrementalUpdate().

◆ updateLinksTimestamp()

LinksUpdate::updateLinksTimestamp ( )
protected

Update links table freshness.

Definition at line 855 of file LinksUpdate.php.

References $timestamp, and array().

Referenced by doIncrementalUpdate().

Member Data Documentation

◆ $linkDeletions

null array LinksUpdate::$linkDeletions = null
private

Deleted links if calculated.

Definition at line 63 of file LinksUpdate.php.

◆ $linkInsertions

null array LinksUpdate::$linkInsertions = null
private

Added links if calculated.

Definition at line 59 of file LinksUpdate.php.

◆ $mCategories

array LinksUpdate::$mCategories

Map of category names to sort keys *.

Definition at line 45 of file LinksUpdate.php.

◆ $mDb

DatabaseBase LinksUpdate::$mDb

Database connection reference *.

Definition at line 51 of file LinksUpdate.php.

◆ $mExternals

array LinksUpdate::$mExternals

URLs of external links, array key only *.

Definition at line 43 of file LinksUpdate.php.

◆ $mId

int LinksUpdate::$mId

Page ID of the article linked from *.

Definition at line 31 of file LinksUpdate.php.

Referenced by getExternalInsertions().

◆ $mImages

array LinksUpdate::$mImages

DB keys of the images used, in the array key only *.

Definition at line 39 of file LinksUpdate.php.

Referenced by getImages().

◆ $mInterlangs

array LinksUpdate::$mInterlangs

ap of language codes to titles *

Definition at line 47 of file LinksUpdate.php.

◆ $mLinks

array LinksUpdate::$mLinks

Map of title strings to IDs for the links in the document *.

Definition at line 37 of file LinksUpdate.php.

◆ $mOptions

array LinksUpdate::$mOptions

SELECT options to be used *.

Definition at line 53 of file LinksUpdate.php.

◆ $mParserOutput

ParserOutput LinksUpdate::$mParserOutput

Definition at line 35 of file LinksUpdate.php.

Referenced by getParserOutput().

◆ $mProperties

array LinksUpdate::$mProperties

Map of arbitrary name to value *.

Definition at line 49 of file LinksUpdate.php.

◆ $mRecursive

bool LinksUpdate::$mRecursive

Whether to queue jobs for recursive updates *.

Definition at line 55 of file LinksUpdate.php.

◆ $mTemplates

array LinksUpdate::$mTemplates

Map of title strings to IDs for the template references, including broken ones *.

Definition at line 41 of file LinksUpdate.php.

◆ $mTitle

Title LinksUpdate::$mTitle

object of the article linked from *

Definition at line 33 of file LinksUpdate.php.

Referenced by getTitle().


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