3 * Updater for link tracking tables after a page edit.
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * http://www.gnu.org/copyleft/gpl.html
24 * See docs/deferred.txt
26 * @todo document (e.g. one-sentence top-level class description).
28 class LinksUpdate
extends SqlDataUpdate
implements EnqueueableDataUpdate
{
29 // @todo make members protected, but make sure extensions don't break
31 /** @var int Page ID of the article linked from */
34 /** @var Title Title object of the article linked from */
37 /** @var ParserOutput */
38 public $mParserOutput;
40 /** @var array Map of title strings to IDs for the links in the document */
43 /** @var array DB keys of the images used, in the array key only */
46 /** @var array Map of title strings to IDs for the template references, including broken ones */
49 /** @var array URLs of external links, array key only */
52 /** @var array Map of category names to sort keys */
55 /** @var array Map of language codes to titles */
58 /** @var array Map of arbitrary name to value */
61 /** @var bool Whether to queue jobs for recursive updates */
64 /** @var bool Whether this job was triggered by a recursive update job */
65 private $mTriggeredRecursive;
67 /** @var Revision Revision for which this update has been triggered */
71 * @var null|array Added links if calculated.
73 private $linkInsertions = null;
76 * @var null|array Deleted links if calculated.
78 private $linkDeletions = null;
83 * @param Title $title Title of the page we're updating
84 * @param ParserOutput $parserOutput Output from a full parse of this page
85 * @param bool $recursive Queue jobs for recursive updates?
88 function __construct( Title
$title, ParserOutput
$parserOutput, $recursive = true ) {
89 parent
::__construct( false ); // no implicit transaction
91 $this->mTitle
= $title;
92 $this->mId
= $title->getArticleID();
95 throw new InvalidArgumentException(
96 "The Title object yields no ID. Perhaps the page doesn't exist?"
100 $this->mParserOutput
= $parserOutput;
102 $this->mLinks
= $parserOutput->getLinks();
103 $this->mImages
= $parserOutput->getImages();
104 $this->mTemplates
= $parserOutput->getTemplates();
105 $this->mExternals
= $parserOutput->getExternalLinks();
106 $this->mCategories
= $parserOutput->getCategories();
107 $this->mProperties
= $parserOutput->getProperties();
108 $this->mInterwikis
= $parserOutput->getInterwikiLinks();
110 # Convert the format of the interlanguage links
111 # I didn't want to change it in the ParserOutput, because that array is passed all
112 # the way back to the skin, so either a skin API break would be required, or an
113 # inefficient back-conversion.
114 $ill = $parserOutput->getLanguageLinks();
115 $this->mInterlangs
= array();
116 foreach ( $ill as $link ) {
117 list( $key, $title ) = explode( ':', $link, 2 );
118 $this->mInterlangs
[$key] = $title;
121 foreach ( $this->mCategories
as &$sortkey ) {
122 # If the sortkey is longer then 255 bytes,
123 # it truncated by DB, and then doesn't get
124 # matched when comparing existing vs current
125 # categories, causing bug 25254.
126 # Also. substr behaves weird when given "".
127 if ( $sortkey !== '' ) {
128 $sortkey = substr( $sortkey, 0, 255 );
132 $this->mRecursive
= $recursive;
134 Hooks
::run( 'LinksUpdateConstructed', array( &$this ) );
138 * Update link tables with outgoing links from an updated article
140 public function doUpdate() {
141 Hooks
::run( 'LinksUpdate', array( &$this ) );
142 $this->doIncrementalUpdate();
143 Hooks
::run( 'LinksUpdateComplete', array( &$this ) );
146 protected function doIncrementalUpdate() {
147 global $wgRCWatchCategoryMembership;
150 $existing = $this->getExistingLinks();
151 $this->linkDeletions
= $this->getLinkDeletions( $existing );
152 $this->linkInsertions
= $this->getLinkInsertions( $existing );
153 $this->incrTableUpdate( 'pagelinks', 'pl', $this->linkDeletions
, $this->linkInsertions
);
156 $existing = $this->getExistingImages();
158 $imageDeletes = $this->getImageDeletions( $existing );
159 $this->incrTableUpdate( 'imagelinks', 'il', $imageDeletes,
160 $this->getImageInsertions( $existing ) );
162 # Invalidate all image description pages which had links added or removed
163 $imageUpdates = $imageDeletes +
array_diff_key( $this->mImages
, $existing );
164 $this->invalidateImageDescriptions( $imageUpdates );
167 $existing = $this->getExistingExternals();
168 $this->incrTableUpdate( 'externallinks', 'el', $this->getExternalDeletions( $existing ),
169 $this->getExternalInsertions( $existing ) );
172 $existing = $this->getExistingInterlangs();
173 $this->incrTableUpdate( 'langlinks', 'll', $this->getInterlangDeletions( $existing ),
174 $this->getInterlangInsertions( $existing ) );
176 # Inline interwiki links
177 $existing = $this->getExistingInterwikis();
178 $this->incrTableUpdate( 'iwlinks', 'iwl', $this->getInterwikiDeletions( $existing ),
179 $this->getInterwikiInsertions( $existing ) );
182 $existing = $this->getExistingTemplates();
183 $this->incrTableUpdate( 'templatelinks', 'tl', $this->getTemplateDeletions( $existing ),
184 $this->getTemplateInsertions( $existing ) );
187 $existing = $this->getExistingCategories();
189 $categoryDeletes = $this->getCategoryDeletions( $existing );
191 $this->incrTableUpdate( 'categorylinks', 'cl', $categoryDeletes,
192 $this->getCategoryInsertions( $existing ) );
194 # Invalidate all categories which were added, deleted or changed (set symmetric difference)
195 $categoryInserts = array_diff_assoc( $this->mCategories
, $existing );
196 $categoryUpdates = $categoryInserts +
$categoryDeletes;
197 $this->invalidateCategories( $categoryUpdates );
198 $this->updateCategoryCounts( $categoryInserts, $categoryDeletes );
200 # Category membership changes
202 $wgRCWatchCategoryMembership &&
203 !$this->mTriggeredRecursive
&& ( $categoryInserts ||
$categoryDeletes )
205 $this->triggerCategoryChanges( $categoryInserts, $categoryDeletes );
209 $existing = $this->getExistingProperties();
211 $propertiesDeletes = $this->getPropertyDeletions( $existing );
213 $this->incrTableUpdate( 'page_props', 'pp', $propertiesDeletes,
214 $this->getPropertyInsertions( $existing ) );
216 # Invalidate the necessary pages
217 $changed = $propertiesDeletes +
array_diff_assoc( $this->mProperties
, $existing );
218 $this->invalidateProperties( $changed );
220 # Update the links table freshness for this title
221 $this->updateLinksTimestamp();
223 # Refresh links of all pages including this page
224 # This will be in a separate transaction
225 if ( $this->mRecursive
) {
226 $this->queueRecursiveJobs();
231 private function triggerCategoryChanges( $categoryInserts, $categoryDeletes ) {
232 $catMembChange = new CategoryMembershipChange( $this->mTitle
, $this->mRevision
);
234 if ( $this->mRecursive
) {
235 $catMembChange->checkTemplateLinks();
238 foreach ( $categoryInserts as $categoryName => $value ) {
239 $categoryTitle = Title
::newFromText( $categoryName, NS_CATEGORY
);
240 $catMembChange->triggerCategoryAddedNotification( $categoryTitle );
243 foreach ( $categoryDeletes as $categoryName => $value ) {
244 $categoryTitle = Title
::newFromText( $categoryName, NS_CATEGORY
);
245 $catMembChange->triggerCategoryRemovedNotification( $categoryTitle );
250 * Queue recursive jobs for this page
252 * Which means do LinksUpdate on all pages that include the current page,
253 * using the job queue.
255 protected function queueRecursiveJobs() {
256 self
::queueRecursiveJobsForTable( $this->mTitle
, 'templatelinks' );
257 if ( $this->mTitle
->getNamespace() == NS_FILE
) {
258 // Process imagelinks in case the title is or was a redirect
259 self
::queueRecursiveJobsForTable( $this->mTitle
, 'imagelinks' );
262 $bc = $this->mTitle
->getBacklinkCache();
263 // Get jobs for cascade-protected backlinks for a high priority queue.
264 // If meta-templates change to using a new template, the new template
265 // should be implicitly protected as soon as possible, if applicable.
266 // These jobs duplicate a subset of the above ones, but can run sooner.
267 // Which ever runs first generally no-ops the other one.
269 foreach ( $bc->getCascadeProtectedLinks() as $title ) {
270 $jobs[] = new RefreshLinksJob( $title, array( 'prioritize' => true ) );
272 JobQueueGroup
::singleton()->push( $jobs );
276 * Queue a RefreshLinks job for any table.
278 * @param Title $title Title to do job for
279 * @param string $table Table to use (e.g. 'templatelinks')
281 public static function queueRecursiveJobsForTable( Title
$title, $table ) {
282 if ( $title->getBacklinkCache()->hasLinks( $table ) ) {
283 $job = new RefreshLinksJob(
288 ) + Job
::newRootJobParams( // "overall" refresh links job info
289 "refreshlinks:{$table}:{$title->getPrefixedText()}"
293 JobQueueGroup
::singleton()->push( $job );
300 function invalidateCategories( $cats ) {
301 $this->invalidatePages( NS_CATEGORY
, array_keys( $cats ) );
305 * Update all the appropriate counts in the category table.
306 * @param array $added Associative array of category name => sort key
307 * @param array $deleted Associative array of category name => sort key
309 function updateCategoryCounts( $added, $deleted ) {
310 $a = WikiPage
::factory( $this->mTitle
);
311 $a->updateCategoryCounts(
312 array_keys( $added ), array_keys( $deleted )
317 * @param array $images
319 function invalidateImageDescriptions( $images ) {
320 $this->invalidatePages( NS_FILE
, array_keys( $images ) );
324 * Update a table by doing a delete query then an insert query
325 * @param string $table Table name
326 * @param string $prefix Field name prefix
327 * @param array $deletions
328 * @param array $insertions Rows to insert
330 function incrTableUpdate( $table, $prefix, $deletions, $insertions ) {
331 if ( $table == 'page_props' ) {
332 $fromField = 'pp_page';
334 $fromField = "{$prefix}_from";
336 $where = array( $fromField => $this->mId
);
337 if ( $table == 'pagelinks' ||
$table == 'templatelinks' ||
$table == 'iwlinks' ) {
338 if ( $table == 'iwlinks' ) {
339 $baseKey = 'iwl_prefix';
341 $baseKey = "{$prefix}_namespace";
343 $clause = $this->mDb
->makeWhereFrom2d( $deletions, $baseKey, "{$prefix}_title" );
350 if ( $table == 'langlinks' ) {
351 $toField = 'll_lang';
352 } elseif ( $table == 'page_props' ) {
353 $toField = 'pp_propname';
355 $toField = $prefix . '_to';
357 if ( count( $deletions ) ) {
358 $where[$toField] = array_keys( $deletions );
364 $this->mDb
->delete( $table, $where, __METHOD__
);
366 if ( count( $insertions ) ) {
367 $this->mDb
->insert( $table, $insertions, __METHOD__
, 'IGNORE' );
368 Hooks
::run( 'LinksUpdateAfterInsert', array( $this, $table, $insertions ) );
373 * Get an array of pagelinks insertions for passing to the DB
374 * Skips the titles specified by the 2-D array $existing
375 * @param array $existing
378 private function getLinkInsertions( $existing = array() ) {
380 foreach ( $this->mLinks
as $ns => $dbkeys ) {
381 $diffs = isset( $existing[$ns] )
382 ?
array_diff_key( $dbkeys, $existing[$ns] )
384 foreach ( $diffs as $dbk => $id ) {
386 'pl_from' => $this->mId
,
387 'pl_from_namespace' => $this->mTitle
->getNamespace(),
388 'pl_namespace' => $ns,
398 * Get an array of template insertions. Like getLinkInsertions()
399 * @param array $existing
402 private function getTemplateInsertions( $existing = array() ) {
404 foreach ( $this->mTemplates
as $ns => $dbkeys ) {
405 $diffs = isset( $existing[$ns] ) ?
array_diff_key( $dbkeys, $existing[$ns] ) : $dbkeys;
406 foreach ( $diffs as $dbk => $id ) {
408 'tl_from' => $this->mId
,
409 'tl_from_namespace' => $this->mTitle
->getNamespace(),
410 'tl_namespace' => $ns,
420 * Get an array of image insertions
421 * Skips the names specified in $existing
422 * @param array $existing
425 private function getImageInsertions( $existing = array() ) {
427 $diffs = array_diff_key( $this->mImages
, $existing );
428 foreach ( $diffs as $iname => $dummy ) {
430 'il_from' => $this->mId
,
431 'il_from_namespace' => $this->mTitle
->getNamespace(),
440 * Get an array of externallinks insertions. Skips the names specified in $existing
441 * @param array $existing
444 private function getExternalInsertions( $existing = array() ) {
446 $diffs = array_diff_key( $this->mExternals
, $existing );
447 foreach ( $diffs as $url => $dummy ) {
448 foreach ( wfMakeUrlIndexes( $url ) as $index ) {
450 'el_id' => $this->mDb
->nextSequenceValue( 'externallinks_el_id_seq' ),
451 'el_from' => $this->mId
,
453 'el_index' => $index,
462 * Get an array of category insertions
464 * @param array $existing Mapping existing category names to sort keys. If both
465 * match a link in $this, the link will be omitted from the output
469 private function getCategoryInsertions( $existing = array() ) {
470 global $wgContLang, $wgCategoryCollation;
471 $diffs = array_diff_assoc( $this->mCategories
, $existing );
473 foreach ( $diffs as $name => $prefix ) {
474 $nt = Title
::makeTitleSafe( NS_CATEGORY
, $name );
475 $wgContLang->findVariantLink( $name, $nt, true );
477 if ( $this->mTitle
->getNamespace() == NS_CATEGORY
) {
479 } elseif ( $this->mTitle
->getNamespace() == NS_FILE
) {
485 # Treat custom sortkeys as a prefix, so that if multiple
486 # things are forced to sort as '*' or something, they'll
487 # sort properly in the category rather than in page_id
489 $sortkey = Collation
::singleton()->getSortKey(
490 $this->mTitle
->getCategorySortkey( $prefix ) );
493 'cl_from' => $this->mId
,
495 'cl_sortkey' => $sortkey,
496 'cl_timestamp' => $this->mDb
->timestamp(),
497 'cl_sortkey_prefix' => $prefix,
498 'cl_collation' => $wgCategoryCollation,
507 * Get an array of interlanguage link insertions
509 * @param array $existing Mapping existing language codes to titles
513 private function getInterlangInsertions( $existing = array() ) {
514 $diffs = array_diff_assoc( $this->mInterlangs
, $existing );
516 foreach ( $diffs as $lang => $title ) {
518 'll_from' => $this->mId
,
528 * Get an array of page property insertions
529 * @param array $existing
532 function getPropertyInsertions( $existing = array() ) {
533 $diffs = array_diff_assoc( $this->mProperties
, $existing );
536 foreach ( array_keys( $diffs ) as $name ) {
537 $arr[] = $this->getPagePropRowData( $name );
544 * Returns an associative array to be used for inserting a row into
545 * the page_props table. Besides the given property name, this will
546 * include the page id from $this->mId and any property value from
547 * $this->mProperties.
549 * The array returned will include the pp_sortkey field if this
550 * is present in the database (as indicated by $wgPagePropsHaveSortkey).
551 * The sortkey value is currently determined by getPropertySortKeyValue().
553 * @note this assumes that $this->mProperties[$prop] is defined.
555 * @param string $prop The name of the property.
559 private function getPagePropRowData( $prop ) {
560 global $wgPagePropsHaveSortkey;
562 $value = $this->mProperties
[$prop];
565 'pp_page' => $this->mId
,
566 'pp_propname' => $prop,
567 'pp_value' => $value,
570 if ( $wgPagePropsHaveSortkey ) {
571 $row['pp_sortkey'] = $this->getPropertySortKeyValue( $value );
578 * Determines the sort key for the given property value.
579 * This will return $value if it is a float or int,
580 * 1 or resp. 0 if it is a bool, and null otherwise.
582 * @note In the future, we may allow the sortkey to be specified explicitly
583 * in ParserOutput::setProperty.
585 * @param mixed $value
589 private function getPropertySortKeyValue( $value ) {
590 if ( is_int( $value ) ||
is_float( $value ) ||
is_bool( $value ) ) {
591 return floatval( $value );
598 * Get an array of interwiki insertions for passing to the DB
599 * Skips the titles specified by the 2-D array $existing
600 * @param array $existing
603 private function getInterwikiInsertions( $existing = array() ) {
605 foreach ( $this->mInterwikis
as $prefix => $dbkeys ) {
606 $diffs = isset( $existing[$prefix] )
607 ?
array_diff_key( $dbkeys, $existing[$prefix] )
610 foreach ( $diffs as $dbk => $id ) {
612 'iwl_from' => $this->mId
,
613 'iwl_prefix' => $prefix,
623 * Given an array of existing links, returns those links which are not in $this
624 * and thus should be deleted.
625 * @param array $existing
628 private function getLinkDeletions( $existing ) {
630 foreach ( $existing as $ns => $dbkeys ) {
631 if ( isset( $this->mLinks
[$ns] ) ) {
632 $del[$ns] = array_diff_key( $existing[$ns], $this->mLinks
[$ns] );
634 $del[$ns] = $existing[$ns];
642 * Given an array of existing templates, returns those templates which are not in $this
643 * and thus should be deleted.
644 * @param array $existing
647 private function getTemplateDeletions( $existing ) {
649 foreach ( $existing as $ns => $dbkeys ) {
650 if ( isset( $this->mTemplates
[$ns] ) ) {
651 $del[$ns] = array_diff_key( $existing[$ns], $this->mTemplates
[$ns] );
653 $del[$ns] = $existing[$ns];
661 * Given an array of existing images, returns those images which are not in $this
662 * and thus should be deleted.
663 * @param array $existing
666 private function getImageDeletions( $existing ) {
667 return array_diff_key( $existing, $this->mImages
);
671 * Given an array of existing external links, returns those links which are not
672 * in $this and thus should be deleted.
673 * @param array $existing
676 private function getExternalDeletions( $existing ) {
677 return array_diff_key( $existing, $this->mExternals
);
681 * Given an array of existing categories, returns those categories which are not in $this
682 * and thus should be deleted.
683 * @param array $existing
686 private function getCategoryDeletions( $existing ) {
687 return array_diff_assoc( $existing, $this->mCategories
);
691 * Given an array of existing interlanguage links, returns those links which are not
692 * in $this and thus should be deleted.
693 * @param array $existing
696 private function getInterlangDeletions( $existing ) {
697 return array_diff_assoc( $existing, $this->mInterlangs
);
701 * Get array of properties which should be deleted.
702 * @param array $existing
705 function getPropertyDeletions( $existing ) {
706 return array_diff_assoc( $existing, $this->mProperties
);
710 * Given an array of existing interwiki links, returns those links which are not in $this
711 * and thus should be deleted.
712 * @param array $existing
715 private function getInterwikiDeletions( $existing ) {
717 foreach ( $existing as $prefix => $dbkeys ) {
718 if ( isset( $this->mInterwikis
[$prefix] ) ) {
719 $del[$prefix] = array_diff_key( $existing[$prefix], $this->mInterwikis
[$prefix] );
721 $del[$prefix] = $existing[$prefix];
729 * Get an array of existing links, as a 2-D array
733 private function getExistingLinks() {
734 $res = $this->mDb
->select( 'pagelinks', array( 'pl_namespace', 'pl_title' ),
735 array( 'pl_from' => $this->mId
), __METHOD__
, $this->mOptions
);
737 foreach ( $res as $row ) {
738 if ( !isset( $arr[$row->pl_namespace
] ) ) {
739 $arr[$row->pl_namespace
] = array();
741 $arr[$row->pl_namespace
][$row->pl_title
] = 1;
748 * Get an array of existing templates, as a 2-D array
752 private function getExistingTemplates() {
753 $res = $this->mDb
->select( 'templatelinks', array( 'tl_namespace', 'tl_title' ),
754 array( 'tl_from' => $this->mId
), __METHOD__
, $this->mOptions
);
756 foreach ( $res as $row ) {
757 if ( !isset( $arr[$row->tl_namespace
] ) ) {
758 $arr[$row->tl_namespace
] = array();
760 $arr[$row->tl_namespace
][$row->tl_title
] = 1;
767 * Get an array of existing images, image names in the keys
771 private function getExistingImages() {
772 $res = $this->mDb
->select( 'imagelinks', array( 'il_to' ),
773 array( 'il_from' => $this->mId
), __METHOD__
, $this->mOptions
);
775 foreach ( $res as $row ) {
776 $arr[$row->il_to
] = 1;
783 * Get an array of existing external links, URLs in the keys
787 private function getExistingExternals() {
788 $res = $this->mDb
->select( 'externallinks', array( 'el_to' ),
789 array( 'el_from' => $this->mId
), __METHOD__
, $this->mOptions
);
791 foreach ( $res as $row ) {
792 $arr[$row->el_to
] = 1;
799 * Get an array of existing categories, with the name in the key and sort key in the value.
803 private function getExistingCategories() {
804 $res = $this->mDb
->select( 'categorylinks', array( 'cl_to', 'cl_sortkey_prefix' ),
805 array( 'cl_from' => $this->mId
), __METHOD__
, $this->mOptions
);
807 foreach ( $res as $row ) {
808 $arr[$row->cl_to
] = $row->cl_sortkey_prefix
;
815 * Get an array of existing interlanguage links, with the language code in the key and the
816 * title in the value.
820 private function getExistingInterlangs() {
821 $res = $this->mDb
->select( 'langlinks', array( 'll_lang', 'll_title' ),
822 array( 'll_from' => $this->mId
), __METHOD__
, $this->mOptions
);
824 foreach ( $res as $row ) {
825 $arr[$row->ll_lang
] = $row->ll_title
;
832 * Get an array of existing inline interwiki links, as a 2-D array
833 * @return array (prefix => array(dbkey => 1))
835 protected function getExistingInterwikis() {
836 $res = $this->mDb
->select( 'iwlinks', array( 'iwl_prefix', 'iwl_title' ),
837 array( 'iwl_from' => $this->mId
), __METHOD__
, $this->mOptions
);
839 foreach ( $res as $row ) {
840 if ( !isset( $arr[$row->iwl_prefix
] ) ) {
841 $arr[$row->iwl_prefix
] = array();
843 $arr[$row->iwl_prefix
][$row->iwl_title
] = 1;
850 * Get an array of existing categories, with the name in the key and sort key in the value.
852 * @return array Array of property names and values
854 private function getExistingProperties() {
855 $res = $this->mDb
->select( 'page_props', array( 'pp_propname', 'pp_value' ),
856 array( 'pp_page' => $this->mId
), __METHOD__
, $this->mOptions
);
858 foreach ( $res as $row ) {
859 $arr[$row->pp_propname
] = $row->pp_value
;
866 * Return the title object of the page being updated
869 public function getTitle() {
870 return $this->mTitle
;
874 * Returns parser output
876 * @return ParserOutput
878 public function getParserOutput() {
879 return $this->mParserOutput
;
883 * Return the list of images used as generated by the parser
886 public function getImages() {
887 return $this->mImages
;
891 * Set this object as being triggered by a recursive LinksUpdate
895 public function setTriggeredRecursive() {
896 $this->mTriggeredRecursive
= true;
900 * Set the revision corresponding to this LinksUpdate
904 * @param Revision $revision
906 public function setRevision( Revision
$revision ) {
907 $this->mRevision
= $revision;
911 * Invalidate any necessary link lists related to page property changes
912 * @param array $changed
914 private function invalidateProperties( $changed ) {
915 global $wgPagePropLinkInvalidations;
917 foreach ( $changed as $name => $value ) {
918 if ( isset( $wgPagePropLinkInvalidations[$name] ) ) {
919 $inv = $wgPagePropLinkInvalidations[$name];
920 if ( !is_array( $inv ) ) {
921 $inv = array( $inv );
923 foreach ( $inv as $table ) {
924 $update = new HTMLCacheUpdate( $this->mTitle
, $table );
932 * Fetch page links added by this LinksUpdate. Only available after the update is complete.
934 * @return null|array Array of Titles
936 public function getAddedLinks() {
937 if ( $this->linkInsertions
=== null ) {
941 foreach ( $this->linkInsertions
as $insertion ) {
942 $result[] = Title
::makeTitle( $insertion['pl_namespace'], $insertion['pl_title'] );
949 * Fetch page links removed by this LinksUpdate. Only available after the update is complete.
951 * @return null|array Array of Titles
953 public function getRemovedLinks() {
954 if ( $this->linkDeletions
=== null ) {
958 foreach ( $this->linkDeletions
as $ns => $titles ) {
959 foreach ( $titles as $title => $unused ) {
960 $result[] = Title
::makeTitle( $ns, $title );
968 * Update links table freshness
970 protected function updateLinksTimestamp() {
972 // The link updates made here only reflect the freshness of the parser output
973 $timestamp = $this->mParserOutput
->getCacheTime();
974 $this->mDb
->update( 'page',
975 array( 'page_links_updated' => $this->mDb
->timestamp( $timestamp ) ),
976 array( 'page_id' => $this->mId
),
982 public function getAsJobSpecification() {
984 'wiki' => $this->mDb
->getWikiID(),
985 'job' => new JobSpecification(
986 'refreshLinksPrioritized',
988 'prioritize' => true,
989 // Reuse the parser cache if it was saved
990 'rootJobTimestamp' => $this->mParserOutput
->getCacheTime(),
991 'useRecursiveLinksUpdate' => $this->mRecursive
993 array( 'removeDuplicates' => true ),