MediaWiki  1.27.3
LinksUpdate.php
Go to the documentation of this file.
1 <?php
29  // @todo make members protected, but make sure extensions don't break
30 
32  public $mId;
33 
35  public $mTitle;
36 
39 
41  public $mLinks;
42 
44  public $mImages;
45 
47  public $mTemplates;
48 
50  public $mExternals;
51 
53  public $mCategories;
54 
56  public $mInterlangs;
57 
59  public $mInterwikis;
60 
62  public $mProperties;
63 
65  public $mRecursive;
66 
68  private $mRevision;
69 
73  private $linkInsertions = null;
74 
78  private $linkDeletions = null;
79 
83  private $user;
84 
93  function __construct( Title $title, ParserOutput $parserOutput, $recursive = true ) {
94  parent::__construct( false ); // no implicit transaction
95 
96  $this->mTitle = $title;
97  $this->mId = $title->getArticleID( Title::GAID_FOR_UPDATE );
98 
99  if ( !$this->mId ) {
100  throw new InvalidArgumentException(
101  "The Title object yields no ID. Perhaps the page doesn't exist?"
102  );
103  }
104 
105  $this->mParserOutput = $parserOutput;
106 
107  $this->mLinks = $parserOutput->getLinks();
108  $this->mImages = $parserOutput->getImages();
109  $this->mTemplates = $parserOutput->getTemplates();
110  $this->mExternals = $parserOutput->getExternalLinks();
111  $this->mCategories = $parserOutput->getCategories();
112  $this->mProperties = $parserOutput->getProperties();
113  $this->mInterwikis = $parserOutput->getInterwikiLinks();
114 
115  # Convert the format of the interlanguage links
116  # I didn't want to change it in the ParserOutput, because that array is passed all
117  # the way back to the skin, so either a skin API break would be required, or an
118  # inefficient back-conversion.
119  $ill = $parserOutput->getLanguageLinks();
120  $this->mInterlangs = [];
121  foreach ( $ill as $link ) {
122  list( $key, $title ) = explode( ':', $link, 2 );
123  $this->mInterlangs[$key] = $title;
124  }
125 
126  foreach ( $this->mCategories as &$sortkey ) {
127  # If the sortkey is longer then 255 bytes,
128  # it truncated by DB, and then doesn't get
129  # matched when comparing existing vs current
130  # categories, causing bug 25254.
131  # Also. substr behaves weird when given "".
132  if ( $sortkey !== '' ) {
133  $sortkey = substr( $sortkey, 0, 255 );
134  }
135  }
136 
137  $this->mRecursive = $recursive;
138 
139  // Avoid PHP 7.1 warning from passing $this by reference
140  $linksUpdate = $this;
141  Hooks::run( 'LinksUpdateConstructed', [ &$linksUpdate ] );
142  }
143 
147  public function doUpdate() {
148  // Avoid PHP 7.1 warning from passing $this by reference
149  $linksUpdate = $this;
150  Hooks::run( 'LinksUpdate', [ &$linksUpdate ] );
151  $this->doIncrementalUpdate();
152 
153  $this->mDb->onTransactionIdle( function() {
154  // Avoid PHP 7.1 warning from passing $this by reference
155  $linksUpdate = $this;
156  Hooks::run( 'LinksUpdateComplete', [ &$linksUpdate ] );
157  } );
158  }
159 
160  protected function doIncrementalUpdate() {
161  # Page links
162  $existing = $this->getExistingLinks();
163  $this->linkDeletions = $this->getLinkDeletions( $existing );
164  $this->linkInsertions = $this->getLinkInsertions( $existing );
165  $this->incrTableUpdate( 'pagelinks', 'pl', $this->linkDeletions, $this->linkInsertions );
166 
167  # Image links
168  $existing = $this->getExistingImages();
169 
170  $imageDeletes = $this->getImageDeletions( $existing );
171  $this->incrTableUpdate( 'imagelinks', 'il', $imageDeletes,
172  $this->getImageInsertions( $existing ) );
173 
174  # Invalidate all image description pages which had links added or removed
175  $imageUpdates = $imageDeletes + array_diff_key( $this->mImages, $existing );
176  $this->invalidateImageDescriptions( $imageUpdates );
177 
178  # External links
179  $existing = $this->getExistingExternals();
180  $this->incrTableUpdate( 'externallinks', 'el', $this->getExternalDeletions( $existing ),
181  $this->getExternalInsertions( $existing ) );
182 
183  # Language links
184  $existing = $this->getExistingInterlangs();
185  $this->incrTableUpdate( 'langlinks', 'll', $this->getInterlangDeletions( $existing ),
186  $this->getInterlangInsertions( $existing ) );
187 
188  # Inline interwiki links
189  $existing = $this->getExistingInterwikis();
190  $this->incrTableUpdate( 'iwlinks', 'iwl', $this->getInterwikiDeletions( $existing ),
191  $this->getInterwikiInsertions( $existing ) );
192 
193  # Template links
194  $existing = $this->getExistingTemplates();
195  $this->incrTableUpdate( 'templatelinks', 'tl', $this->getTemplateDeletions( $existing ),
196  $this->getTemplateInsertions( $existing ) );
197 
198  # Category links
199  $existing = $this->getExistingCategories();
200 
201  $categoryDeletes = $this->getCategoryDeletions( $existing );
202 
203  $this->incrTableUpdate( 'categorylinks', 'cl', $categoryDeletes,
204  $this->getCategoryInsertions( $existing ) );
205 
206  # Invalidate all categories which were added, deleted or changed (set symmetric difference)
207  $categoryInserts = array_diff_assoc( $this->mCategories, $existing );
208  $categoryUpdates = $categoryInserts + $categoryDeletes;
209  $this->invalidateCategories( $categoryUpdates );
210  $this->updateCategoryCounts( $categoryInserts, $categoryDeletes );
211 
212  # Page properties
213  $existing = $this->getExistingProperties();
214 
215  $propertiesDeletes = $this->getPropertyDeletions( $existing );
216 
217  $this->incrTableUpdate( 'page_props', 'pp', $propertiesDeletes,
218  $this->getPropertyInsertions( $existing ) );
219 
220  # Invalidate the necessary pages
221  $changed = $propertiesDeletes + array_diff_assoc( $this->mProperties, $existing );
222  $this->invalidateProperties( $changed );
223 
224  # Update the links table freshness for this title
225  $this->updateLinksTimestamp();
226 
227  # Refresh links of all pages including this page
228  # This will be in a separate transaction
229  if ( $this->mRecursive ) {
230  $this->queueRecursiveJobs();
231  }
232 
233  }
234 
241  protected function queueRecursiveJobs() {
242  self::queueRecursiveJobsForTable( $this->mTitle, 'templatelinks' );
243  if ( $this->mTitle->getNamespace() == NS_FILE ) {
244  // Process imagelinks in case the title is or was a redirect
245  self::queueRecursiveJobsForTable( $this->mTitle, 'imagelinks' );
246  }
247 
248  $bc = $this->mTitle->getBacklinkCache();
249  // Get jobs for cascade-protected backlinks for a high priority queue.
250  // If meta-templates change to using a new template, the new template
251  // should be implicitly protected as soon as possible, if applicable.
252  // These jobs duplicate a subset of the above ones, but can run sooner.
253  // Which ever runs first generally no-ops the other one.
254  $jobs = [];
255  foreach ( $bc->getCascadeProtectedLinks() as $title ) {
256  $jobs[] = RefreshLinksJob::newPrioritized( $title, [] );
257  }
258  JobQueueGroup::singleton()->push( $jobs );
259  }
260 
267  public static function queueRecursiveJobsForTable( Title $title, $table ) {
268  if ( $title->getBacklinkCache()->hasLinks( $table ) ) {
269  $job = new RefreshLinksJob(
270  $title,
271  [
272  'table' => $table,
273  'recursive' => true,
274  ] + Job::newRootJobParams( // "overall" refresh links job info
275  "refreshlinks:{$table}:{$title->getPrefixedText()}"
276  )
277  );
278 
279  JobQueueGroup::singleton()->push( $job );
280  }
281  }
282 
286  function invalidateCategories( $cats ) {
287  $this->invalidatePages( NS_CATEGORY, array_keys( $cats ) );
288  }
289 
295  function updateCategoryCounts( $added, $deleted ) {
296  $a = WikiPage::factory( $this->mTitle );
297  $a->updateCategoryCounts(
298  array_keys( $added ), array_keys( $deleted )
299  );
300  }
301 
305  function invalidateImageDescriptions( $images ) {
306  $this->invalidatePages( NS_FILE, array_keys( $images ) );
307  }
308 
316  function incrTableUpdate( $table, $prefix, $deletions, $insertions ) {
317  if ( $table == 'page_props' ) {
318  $fromField = 'pp_page';
319  } else {
320  $fromField = "{$prefix}_from";
321  }
322  $where = [ $fromField => $this->mId ];
323  if ( $table == 'pagelinks' || $table == 'templatelinks' || $table == 'iwlinks' ) {
324  if ( $table == 'iwlinks' ) {
325  $baseKey = 'iwl_prefix';
326  } else {
327  $baseKey = "{$prefix}_namespace";
328  }
329  $clause = $this->mDb->makeWhereFrom2d( $deletions, $baseKey, "{$prefix}_title" );
330  if ( $clause ) {
331  $where[] = $clause;
332  } else {
333  $where = false;
334  }
335  } else {
336  if ( $table == 'langlinks' ) {
337  $toField = 'll_lang';
338  } elseif ( $table == 'page_props' ) {
339  $toField = 'pp_propname';
340  } else {
341  $toField = $prefix . '_to';
342  }
343  if ( count( $deletions ) ) {
344  $where[$toField] = array_keys( $deletions );
345  } else {
346  $where = false;
347  }
348  }
349  if ( $where ) {
350  $this->mDb->delete( $table, $where, __METHOD__ );
351  }
352  if ( count( $insertions ) ) {
353  $this->mDb->insert( $table, $insertions, __METHOD__, 'IGNORE' );
354  Hooks::run( 'LinksUpdateAfterInsert', [ $this, $table, $insertions ] );
355  }
356  }
357 
364  private function getLinkInsertions( $existing = [] ) {
365  $arr = [];
366  foreach ( $this->mLinks as $ns => $dbkeys ) {
367  $diffs = isset( $existing[$ns] )
368  ? array_diff_key( $dbkeys, $existing[$ns] )
369  : $dbkeys;
370  foreach ( $diffs as $dbk => $id ) {
371  $arr[] = [
372  'pl_from' => $this->mId,
373  'pl_from_namespace' => $this->mTitle->getNamespace(),
374  'pl_namespace' => $ns,
375  'pl_title' => $dbk
376  ];
377  }
378  }
379 
380  return $arr;
381  }
382 
388  private function getTemplateInsertions( $existing = [] ) {
389  $arr = [];
390  foreach ( $this->mTemplates as $ns => $dbkeys ) {
391  $diffs = isset( $existing[$ns] ) ? array_diff_key( $dbkeys, $existing[$ns] ) : $dbkeys;
392  foreach ( $diffs as $dbk => $id ) {
393  $arr[] = [
394  'tl_from' => $this->mId,
395  'tl_from_namespace' => $this->mTitle->getNamespace(),
396  'tl_namespace' => $ns,
397  'tl_title' => $dbk
398  ];
399  }
400  }
401 
402  return $arr;
403  }
404 
411  private function getImageInsertions( $existing = [] ) {
412  $arr = [];
413  $diffs = array_diff_key( $this->mImages, $existing );
414  foreach ( $diffs as $iname => $dummy ) {
415  $arr[] = [
416  'il_from' => $this->mId,
417  'il_from_namespace' => $this->mTitle->getNamespace(),
418  'il_to' => $iname
419  ];
420  }
421 
422  return $arr;
423  }
424 
430  private function getExternalInsertions( $existing = [] ) {
431  $arr = [];
432  $diffs = array_diff_key( $this->mExternals, $existing );
433  foreach ( $diffs as $url => $dummy ) {
434  foreach ( wfMakeUrlIndexes( $url ) as $index ) {
435  $arr[] = [
436  'el_id' => $this->mDb->nextSequenceValue( 'externallinks_el_id_seq' ),
437  'el_from' => $this->mId,
438  'el_to' => $url,
439  'el_index' => $index,
440  ];
441  }
442  }
443 
444  return $arr;
445  }
446 
455  private function getCategoryInsertions( $existing = [] ) {
456  global $wgContLang, $wgCategoryCollation;
457  $diffs = array_diff_assoc( $this->mCategories, $existing );
458  $arr = [];
459  foreach ( $diffs as $name => $prefix ) {
461  $wgContLang->findVariantLink( $name, $nt, true );
462 
463  if ( $this->mTitle->getNamespace() == NS_CATEGORY ) {
464  $type = 'subcat';
465  } elseif ( $this->mTitle->getNamespace() == NS_FILE ) {
466  $type = 'file';
467  } else {
468  $type = 'page';
469  }
470 
471  # Treat custom sortkeys as a prefix, so that if multiple
472  # things are forced to sort as '*' or something, they'll
473  # sort properly in the category rather than in page_id
474  # order or such.
475  $sortkey = Collation::singleton()->getSortKey(
476  $this->mTitle->getCategorySortkey( $prefix ) );
477 
478  $arr[] = [
479  'cl_from' => $this->mId,
480  'cl_to' => $name,
481  'cl_sortkey' => $sortkey,
482  'cl_timestamp' => $this->mDb->timestamp(),
483  'cl_sortkey_prefix' => $prefix,
484  'cl_collation' => $wgCategoryCollation,
485  'cl_type' => $type,
486  ];
487  }
488 
489  return $arr;
490  }
491 
499  private function getInterlangInsertions( $existing = [] ) {
500  $diffs = array_diff_assoc( $this->mInterlangs, $existing );
501  $arr = [];
502  foreach ( $diffs as $lang => $title ) {
503  $arr[] = [
504  'll_from' => $this->mId,
505  'll_lang' => $lang,
506  'll_title' => $title
507  ];
508  }
509 
510  return $arr;
511  }
512 
518  function getPropertyInsertions( $existing = [] ) {
519  $diffs = array_diff_assoc( $this->mProperties, $existing );
520 
521  $arr = [];
522  foreach ( array_keys( $diffs ) as $name ) {
523  $arr[] = $this->getPagePropRowData( $name );
524  }
525 
526  return $arr;
527  }
528 
545  private function getPagePropRowData( $prop ) {
546  global $wgPagePropsHaveSortkey;
547 
548  $value = $this->mProperties[$prop];
549 
550  $row = [
551  'pp_page' => $this->mId,
552  'pp_propname' => $prop,
553  'pp_value' => $value,
554  ];
555 
556  if ( $wgPagePropsHaveSortkey ) {
557  $row['pp_sortkey'] = $this->getPropertySortKeyValue( $value );
558  }
559 
560  return $row;
561  }
562 
575  private function getPropertySortKeyValue( $value ) {
576  if ( is_int( $value ) || is_float( $value ) || is_bool( $value ) ) {
577  return floatval( $value );
578  }
579 
580  return null;
581  }
582 
589  private function getInterwikiInsertions( $existing = [] ) {
590  $arr = [];
591  foreach ( $this->mInterwikis as $prefix => $dbkeys ) {
592  $diffs = isset( $existing[$prefix] )
593  ? array_diff_key( $dbkeys, $existing[$prefix] )
594  : $dbkeys;
595 
596  foreach ( $diffs as $dbk => $id ) {
597  $arr[] = [
598  'iwl_from' => $this->mId,
599  'iwl_prefix' => $prefix,
600  'iwl_title' => $dbk
601  ];
602  }
603  }
604 
605  return $arr;
606  }
607 
614  private function getLinkDeletions( $existing ) {
615  $del = [];
616  foreach ( $existing as $ns => $dbkeys ) {
617  if ( isset( $this->mLinks[$ns] ) ) {
618  $del[$ns] = array_diff_key( $existing[$ns], $this->mLinks[$ns] );
619  } else {
620  $del[$ns] = $existing[$ns];
621  }
622  }
623 
624  return $del;
625  }
626 
633  private function getTemplateDeletions( $existing ) {
634  $del = [];
635  foreach ( $existing as $ns => $dbkeys ) {
636  if ( isset( $this->mTemplates[$ns] ) ) {
637  $del[$ns] = array_diff_key( $existing[$ns], $this->mTemplates[$ns] );
638  } else {
639  $del[$ns] = $existing[$ns];
640  }
641  }
642 
643  return $del;
644  }
645 
652  private function getImageDeletions( $existing ) {
653  return array_diff_key( $existing, $this->mImages );
654  }
655 
662  private function getExternalDeletions( $existing ) {
663  return array_diff_key( $existing, $this->mExternals );
664  }
665 
672  private function getCategoryDeletions( $existing ) {
673  return array_diff_assoc( $existing, $this->mCategories );
674  }
675 
682  private function getInterlangDeletions( $existing ) {
683  return array_diff_assoc( $existing, $this->mInterlangs );
684  }
685 
691  function getPropertyDeletions( $existing ) {
692  return array_diff_assoc( $existing, $this->mProperties );
693  }
694 
701  private function getInterwikiDeletions( $existing ) {
702  $del = [];
703  foreach ( $existing as $prefix => $dbkeys ) {
704  if ( isset( $this->mInterwikis[$prefix] ) ) {
705  $del[$prefix] = array_diff_key( $existing[$prefix], $this->mInterwikis[$prefix] );
706  } else {
707  $del[$prefix] = $existing[$prefix];
708  }
709  }
710 
711  return $del;
712  }
713 
719  private function getExistingLinks() {
720  $res = $this->mDb->select( 'pagelinks', [ 'pl_namespace', 'pl_title' ],
721  [ 'pl_from' => $this->mId ], __METHOD__, $this->mOptions );
722  $arr = [];
723  foreach ( $res as $row ) {
724  if ( !isset( $arr[$row->pl_namespace] ) ) {
725  $arr[$row->pl_namespace] = [];
726  }
727  $arr[$row->pl_namespace][$row->pl_title] = 1;
728  }
729 
730  return $arr;
731  }
732 
738  private function getExistingTemplates() {
739  $res = $this->mDb->select( 'templatelinks', [ 'tl_namespace', 'tl_title' ],
740  [ 'tl_from' => $this->mId ], __METHOD__, $this->mOptions );
741  $arr = [];
742  foreach ( $res as $row ) {
743  if ( !isset( $arr[$row->tl_namespace] ) ) {
744  $arr[$row->tl_namespace] = [];
745  }
746  $arr[$row->tl_namespace][$row->tl_title] = 1;
747  }
748 
749  return $arr;
750  }
751 
757  private function getExistingImages() {
758  $res = $this->mDb->select( 'imagelinks', [ 'il_to' ],
759  [ 'il_from' => $this->mId ], __METHOD__, $this->mOptions );
760  $arr = [];
761  foreach ( $res as $row ) {
762  $arr[$row->il_to] = 1;
763  }
764 
765  return $arr;
766  }
767 
773  private function getExistingExternals() {
774  $res = $this->mDb->select( 'externallinks', [ 'el_to' ],
775  [ 'el_from' => $this->mId ], __METHOD__, $this->mOptions );
776  $arr = [];
777  foreach ( $res as $row ) {
778  $arr[$row->el_to] = 1;
779  }
780 
781  return $arr;
782  }
783 
789  private function getExistingCategories() {
790  $res = $this->mDb->select( 'categorylinks', [ 'cl_to', 'cl_sortkey_prefix' ],
791  [ 'cl_from' => $this->mId ], __METHOD__, $this->mOptions );
792  $arr = [];
793  foreach ( $res as $row ) {
794  $arr[$row->cl_to] = $row->cl_sortkey_prefix;
795  }
796 
797  return $arr;
798  }
799 
806  private function getExistingInterlangs() {
807  $res = $this->mDb->select( 'langlinks', [ 'll_lang', 'll_title' ],
808  [ 'll_from' => $this->mId ], __METHOD__, $this->mOptions );
809  $arr = [];
810  foreach ( $res as $row ) {
811  $arr[$row->ll_lang] = $row->ll_title;
812  }
813 
814  return $arr;
815  }
816 
821  protected function getExistingInterwikis() {
822  $res = $this->mDb->select( 'iwlinks', [ 'iwl_prefix', 'iwl_title' ],
823  [ 'iwl_from' => $this->mId ], __METHOD__, $this->mOptions );
824  $arr = [];
825  foreach ( $res as $row ) {
826  if ( !isset( $arr[$row->iwl_prefix] ) ) {
827  $arr[$row->iwl_prefix] = [];
828  }
829  $arr[$row->iwl_prefix][$row->iwl_title] = 1;
830  }
831 
832  return $arr;
833  }
834 
840  private function getExistingProperties() {
841  $res = $this->mDb->select( 'page_props', [ 'pp_propname', 'pp_value' ],
842  [ 'pp_page' => $this->mId ], __METHOD__, $this->mOptions );
843  $arr = [];
844  foreach ( $res as $row ) {
845  $arr[$row->pp_propname] = $row->pp_value;
846  }
847 
848  return $arr;
849  }
850 
855  public function getTitle() {
856  return $this->mTitle;
857  }
858 
864  public function getParserOutput() {
865  return $this->mParserOutput;
866  }
867 
872  public function getImages() {
873  return $this->mImages;
874  }
875 
883  public function setRevision( Revision $revision ) {
884  $this->mRevision = $revision;
885  }
886 
893  public function setTriggeringUser( User $user ) {
894  $this->user = $user;
895  }
896 
901  public function getTriggeringUser() {
902  return $this->user;
903  }
904 
909  private function invalidateProperties( $changed ) {
910  global $wgPagePropLinkInvalidations;
911 
912  foreach ( $changed as $name => $value ) {
913  if ( isset( $wgPagePropLinkInvalidations[$name] ) ) {
914  $inv = $wgPagePropLinkInvalidations[$name];
915  if ( !is_array( $inv ) ) {
916  $inv = [ $inv ];
917  }
918  foreach ( $inv as $table ) {
919  DeferredUpdates::addUpdate( new HTMLCacheUpdate( $this->mTitle, $table ) );
920  }
921  }
922  }
923  }
924 
930  public function getAddedLinks() {
931  if ( $this->linkInsertions === null ) {
932  return null;
933  }
934  $result = [];
935  foreach ( $this->linkInsertions as $insertion ) {
936  $result[] = Title::makeTitle( $insertion['pl_namespace'], $insertion['pl_title'] );
937  }
938 
939  return $result;
940  }
941 
947  public function getRemovedLinks() {
948  if ( $this->linkDeletions === null ) {
949  return null;
950  }
951  $result = [];
952  foreach ( $this->linkDeletions as $ns => $titles ) {
953  foreach ( $titles as $title => $unused ) {
954  $result[] = Title::makeTitle( $ns, $title );
955  }
956  }
957 
958  return $result;
959  }
960 
964  protected function updateLinksTimestamp() {
965  if ( $this->mId ) {
966  // The link updates made here only reflect the freshness of the parser output
967  $timestamp = $this->mParserOutput->getCacheTime();
968  $this->mDb->update( 'page',
969  [ 'page_links_updated' => $this->mDb->timestamp( $timestamp ) ],
970  [ 'page_id' => $this->mId ],
971  __METHOD__
972  );
973  }
974  }
975 
976  public function getAsJobSpecification() {
977  if ( $this->user ) {
978  $userInfo = [
979  'userId' => $this->user->getId(),
980  'userName' => $this->user->getName(),
981  ];
982  } else {
983  $userInfo = false;
984  }
985 
986  if ( $this->mRevision ) {
987  $triggeringRevisionId = $this->mRevision->getId();
988  } else {
989  $triggeringRevisionId = false;
990  }
991 
992  return [
993  'wiki' => $this->mDb->getWikiID(),
994  'job' => new JobSpecification(
995  'refreshLinksPrioritized',
996  [
997  // Reuse the parser cache if it was saved
998  'rootJobTimestamp' => $this->mParserOutput->getCacheTime(),
999  'useRecursiveLinksUpdate' => $this->mRecursive,
1000  'triggeringUser' => $userInfo,
1001  'triggeringRevisionId' => $triggeringRevisionId,
1002  ],
1003  [ 'removeDuplicates' => true ],
1004  $this->getTitle()
1005  )
1006  ];
1007  }
1008 }
static factory(Title $title)
Create a WikiPage object of the appropriate class for the given title.
Definition: WikiPage.php:99
setRevision(Revision $revision)
Set the revision corresponding to this LinksUpdate.
invalidateProperties($changed)
Invalidate any necessary link lists related to page property changes.
updateLinksTimestamp()
Update links table freshness.
deferred txt A few of the database updates required by various functions here can be deferred until after the result page is displayed to the user For updating the view updating the linked to tables after a etc PHP does not yet have any way to tell the server to actually return and disconnect while still running these but it might have such a feature in the future We handle these by creating a deferred update object and putting those objects on a global list
Definition: deferred.txt:11
queueRecursiveJobs()
Queue recursive jobs for this page.
getImageDeletions($existing)
Given an array of existing images, returns those images which are not in $this and thus should be del...
magic word the default is to use $key to get the and $key value or $key value text $key value html to format the value $key
Definition: hooks.txt:2325
bool $mRecursive
Whether to queue jobs for recursive updates.
Definition: LinksUpdate.php:65
getArticleID($flags=0)
Get the article ID for this Title from the link cache, adding it if necessary.
Definition: Title.php:3187
getPropertySortKeyValue($value)
Determines the sort key for the given property value.
See docs/deferred.txt.
Definition: LinksUpdate.php:28
getCategoryInsertions($existing=[])
Get an array of category insertions.
getExistingInterwikis()
Get an array of existing inline interwiki links, as a 2-D array.
array $mProperties
Map of arbitrary name to value.
Definition: LinksUpdate.php:62
static singleton()
Definition: Collation.php:34
if(!isset($args[0])) $lang
Interface that marks a DataUpdate as enqueuable via the JobQueue.
Definition: DataUpdate.php:156
$value
static newRootJobParams($key)
Get "root job" parameters for a task.
Definition: Job.php:261
wfMakeUrlIndexes($url)
Make URL indexes, appropriate for the el_index field of externallinks.
Revision $mRevision
Revision for which this update has been triggered.
Definition: LinksUpdate.php:68
null array $linkInsertions
Added links if calculated.
Definition: LinksUpdate.php:73
Represents a title within MediaWiki.
Definition: Title.php:34
updateCategoryCounts($added, $deleted)
Update all the appropriate counts in the category table.
when a variable name is used in a it is silently declared as a new local masking the global
Definition: design.txt:93
getExistingProperties()
Get an array of existing categories, with the name in the key and sort key in the value...
Title $mTitle
Title object of the article linked from.
Definition: LinksUpdate.php:35
getBacklinkCache()
Get a backlink cache object.
Definition: Title.php:4591
__construct(Title $title, ParserOutput $parserOutput, $recursive=true)
Constructor.
Definition: LinksUpdate.php:93
getPagePropRowData($prop)
Returns an associative array to be used for inserting a row into the page_props table.
getExistingInterlangs()
Get an array of existing interlanguage links, with the language code in the key and the title in the ...
static queueRecursiveJobsForTable(Title $title, $table)
Queue a RefreshLinks job for any table.
The index of the header message $result[1]=The index of the body text message $result[2 through n]=Parameters passed to body text message.Please note the header message cannot receive/use parameters. 'ImportHandleLogItemXMLTag':When parsing a XML tag in a log item.Return false to stop further processing of the tag $reader:XMLReader object $logInfo:Array of information 'ImportHandlePageXMLTag':When parsing a XML tag in a page.Return false to stop further processing of the tag $reader:XMLReader object &$pageInfo:Array of information 'ImportHandleRevisionXMLTag':When parsing a XML tag in a page revision.Return false to stop further processing of the tag $reader:XMLReader object $pageInfo:Array of page information $revisionInfo:Array of revision information 'ImportHandleToplevelXMLTag':When parsing a top level XML tag.Return false to stop further processing of the tag $reader:XMLReader object 'ImportHandleUploadXMLTag':When parsing a XML tag in a file upload.Return false to stop further processing of the tag $reader:XMLReader object $revisionInfo:Array of information 'ImportLogInterwikiLink':Hook to change the interwiki link used in log entries and edit summaries for transwiki imports.&$fullInterwikiPrefix:Interwiki prefix, may contain colons.&$pageTitle:String that contains page title. 'ImportSources':Called when reading from the $wgImportSources configuration variable.Can be used to lazy-load the import sources list.&$importSources:The value of $wgImportSources.Modify as necessary.See the comment in DefaultSettings.php for the detail of how to structure this array. 'InfoAction':When building information to display on the action=info page.$context:IContextSource object &$pageInfo:Array of information 'InitializeArticleMaybeRedirect':MediaWiki check to see if title is a redirect.&$title:Title object for the current page &$request:WebRequest &$ignoreRedirect:boolean to skip redirect check &$target:Title/string of redirect target &$article:Article object 'InternalParseBeforeLinks':during Parser's internalParse method before links but after nowiki/noinclude/includeonly/onlyinclude and other processings.&$parser:Parser object &$text:string containing partially parsed text &$stripState:Parser's internal StripState object 'InternalParseBeforeSanitize':during Parser's internalParse method just before the parser removes unwanted/dangerous HTML tags and after nowiki/noinclude/includeonly/onlyinclude and other processings.Ideal for syntax-extensions after template/parser function execution which respect nowiki and HTML-comments.&$parser:Parser object &$text:string containing partially parsed text &$stripState:Parser's internal StripState object 'InterwikiLoadPrefix':When resolving if a given prefix is an interwiki or not.Return true without providing an interwiki to continue interwiki search.$prefix:interwiki prefix we are looking for.&$iwData:output array describing the interwiki with keys iw_url, iw_local, iw_trans and optionally iw_api and iw_wikiid. 'InvalidateEmailComplete':Called after a user's email has been invalidated successfully.$user:user(object) whose email is being invalidated 'IRCLineURL':When constructing the URL to use in an IRC notification.Callee may modify $url and $query, URL will be constructed as $url.$query &$url:URL to index.php &$query:Query string $rc:RecentChange object that triggered url generation 'IsFileCacheable':Override the result of Article::isFileCacheable()(if true) &$article:article(object) being checked 'IsTrustedProxy':Override the result of IP::isTrustedProxy() &$ip:IP being check &$result:Change this value to override the result of IP::isTrustedProxy() 'IsUploadAllowedFromUrl':Override the result of UploadFromUrl::isAllowedUrl() $url:URL used to upload from &$allowed:Boolean indicating if uploading is allowed for given URL 'isValidEmailAddr':Override the result of Sanitizer::validateEmail(), for instance to return false if the domain name doesn't match your organization.$addr:The e-mail address entered by the user &$result:Set this and return false to override the internal checks 'isValidPassword':Override the result of User::isValidPassword() $password:The password entered by the user &$result:Set this and return false to override the internal checks $user:User the password is being validated for 'Language::getMessagesFileName':$code:The language code or the language we're looking for a messages file for &$file:The messages file path, you can override this to change the location. 'LanguageGetMagic':DEPRECATED!Use $magicWords in a file listed in $wgExtensionMessagesFiles instead.Use this to define synonyms of magic words depending of the language &$magicExtensions:associative array of magic words synonyms $lang:language code(string) 'LanguageGetNamespaces':Provide custom ordering for namespaces or remove namespaces.Do not use this hook to add namespaces.Use CanonicalNamespaces for that.&$namespaces:Array of namespaces indexed by their numbers 'LanguageGetSpecialPageAliases':DEPRECATED!Use $specialPageAliases in a file listed in $wgExtensionMessagesFiles instead.Use to define aliases of special pages names depending of the language &$specialPageAliases:associative array of magic words synonyms $lang:language code(string) 'LanguageGetTranslatedLanguageNames':Provide translated language names.&$names:array of language code=> language name $code:language of the preferred translations 'LanguageLinks':Manipulate a page's language links.This is called in various places to allow extensions to define the effective language links for a page.$title:The page's Title.&$links:Associative array mapping language codes to prefixed links of the form"language:title".&$linkFlags:Associative array mapping prefixed links to arrays of flags.Currently unused, but planned to provide support for marking individual language links in the UI, e.g.for featured articles. 'LanguageSelector':Hook to change the language selector available on a page.$out:The output page.$cssClassName:CSS class name of the language selector. 'LinkBegin':Used when generating internal and interwiki links in Linker::link(), before processing starts.Return false to skip default processing and return $ret.See documentation for Linker::link() for details on the expected meanings of parameters.$skin:the Skin object $target:the Title that the link is pointing to &$html:the contents that the< a > tag should have(raw HTML) $result
Definition: hooks.txt:1800
ParserOutput $mParserOutput
Definition: LinksUpdate.php:38
the value to return A Title object or null for latest to be modified or replaced by the hook handler or if authentication is not possible after cache objects are set for highlighting & $link
Definition: hooks.txt:2585
getTemplateDeletions($existing)
Given an array of existing templates, returns those templates which are not in $this and thus should ...
getLinkInsertions($existing=[])
Get an array of pagelinks insertions for passing to the DB Skips the titles specified by the 2-D arra...
getInterlangDeletions($existing)
Given an array of existing interlanguage links, returns those links which are not in $this and thus s...
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses just before the function returns a value If you return true
Definition: hooks.txt:1802
getPropertyInsertions($existing=[])
Get an array of page property insertions.
getTitle()
Return the title object of the page being updated.
getExistingCategories()
Get an array of existing categories, with the name in the key and sort key in the value...
array $mImages
DB keys of the images used, in the array key only.
Definition: LinksUpdate.php:44
invalidatePages($namespace, array $dbkeys)
Invalidate the cache of a list of pages from a single namespace.
getExistingExternals()
Get an array of existing external links, URLs in the keys.
getParserOutput()
Returns parser output.
getCategoryDeletions($existing)
Given an array of existing categories, returns those categories which are not in $this and thus shoul...
Class to invalidate the HTML cache of all the pages linking to a given title.
getAddedLinks()
Fetch page links added by this LinksUpdate.
if($limit) $timestamp
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist e g Watchlist removed from all revisions and log entries to which it was applied This gives extensions a chance to take it off their books as the deletion has already been partly carried out by this point or something similar the user will be unable to create the tag set and then return false from the hook function Ensure you consume the ChangeTagAfterDelete hook to carry out custom deletion actions as context $parserOutput
Definition: hooks.txt:1008
$res
Definition: database.txt:21
const GAID_FOR_UPDATE
Used to be GAID_FOR_UPDATE define.
Definition: Title.php:49
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such and we might be restricted by PHP settings such as safe mode or open_basedir We cannot assume that the software even has read access anywhere useful Many shared hosts run all users web applications under the same user
Wikitext formatted, in the key only.
Definition: distributors.txt:9
setTriggeringUser(User $user)
Set the User who triggered this LinksUpdate.
getRemovedLinks()
Fetch page links removed by this LinksUpdate.
const NS_CATEGORY
Definition: Defines.php:83
incrTableUpdate($table, $prefix, $deletions, $insertions)
Update a table by doing a delete query then an insert query.
array $mExternals
URLs of external links, array key only.
Definition: LinksUpdate.php:50
static makeTitleSafe($ns, $title, $fragment= '', $interwiki= '')
Create a new Title from a namespace index and a DB key.
Definition: Title.php:548
array $mTemplates
Map of title strings to IDs for the template references, including broken ones.
Definition: LinksUpdate.php:47
namespace and then decline to actually register it file or subcat img or subcat $title
Definition: hooks.txt:916
static addUpdate(DeferrableUpdate $update, $type=self::POSTSEND)
Add an update to the deferred list.
static run($event, array $args=[], $deprecatedVersion=null)
Call hook functions defined in Hooks::register and $wgHooks.
Definition: Hooks.php:131
invalidateCategories($cats)
getExistingImages()
Get an array of existing images, image names in the keys.
const NS_FILE
Definition: Defines.php:75
getInterlangInsertions($existing=[])
Get an array of interlanguage link insertions.
getTemplateInsertions($existing=[])
Get an array of template insertions.
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
Definition: distributors.txt:9
Abstract base class for update jobs that put some secondary data extracted from article content into ...
getExistingTemplates()
Get an array of existing templates, as a 2-D array.
getExternalInsertions($existing=[])
Get an array of externallinks insertions.
getExistingLinks()
Get an array of existing links, as a 2-D array.
invalidateImageDescriptions($images)
static singleton($wiki=false)
Job to update link tables for pages.
User null $user
Definition: LinksUpdate.php:83
array $mLinks
Map of title strings to IDs for the links in the document.
Definition: LinksUpdate.php:41
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
Definition: injection.txt:35
getExternalDeletions($existing)
Given an array of existing external links, returns those links which are not in $this and thus should...
getInterwikiDeletions($existing)
Given an array of existing interwiki links, returns those links which are not in $this and thus shoul...
linkcache txt The LinkCache class maintains a list of article titles and the information about whether or not the article exists in the database This is used to mark up links when displaying a page If the same link appears more than once on any page then it only has to be looked up once In most cases link lookups are done in batches with the LinkBatch class or the equivalent in so the link cache is mostly useful for short snippets of parsed and for links in the navigation areas of the skin The link cache was formerly used to track links used in a document for the purposes of updating the link tables This application is now deprecated To create a you can use the following $titles
Definition: linkcache.txt:17
if(count($args)< 1) $job
static newPrioritized(Title $title, array $params)
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses just before the function returns a value If you return an< a > element with HTML attributes $attribs and contents $html will be returned If you return $ret will be returned and may include noclasses after processing after in associative array form externallinks $linksUpdate
Definition: hooks.txt:1802
getPropertyDeletions($existing)
Get array of properties which should be deleted.
this class mediates it Skin Encapsulates a look and feel for the wiki All of the functions that render HTML and make choices about how to render it are here and are called from various other places when and is meant to be subclassed with other skins that may override some of its functions The User object contains a reference to a and so rather than having a global skin object we just rely on the global User and get the skin with $wgUser and also has some character encoding functions and other locale stuff The current user interface language is instantiated as and the local content language as $wgContLang
Definition: design.txt:56
getInterwikiInsertions($existing=[])
Get an array of interwiki insertions for passing to the DB Skips the titles specified by the 2-D arra...
getLinkDeletions($existing)
Given an array of existing links, returns those links which are not in $this and thus should be delet...
doUpdate()
Update link tables with outgoing links from an updated article.
null array $linkDeletions
Deleted links if calculated.
Definition: LinksUpdate.php:78
getImages()
Return the list of images used as generated by the parser.
array $mInterlangs
Map of language codes to titles.
Definition: LinksUpdate.php:56
getAsJobSpecification()
int $mId
Page ID of the article linked from.
Definition: LinksUpdate.php:32
getImageInsertions($existing=[])
Get an array of image insertions Skips the names specified in $existing.
array $mCategories
Map of category names to sort keys.
Definition: LinksUpdate.php:53
Job queue task description base code.
do that in ParserLimitReportFormat instead use this to modify the parameters of the image and a DIV can begin in one section and end in another Make sure your code can handle that case gracefully See the EditSectionClearerLink extension for an example zero but section is usually empty its values are the globals values before the output is cached one of or reset my talk my contributions etc etc otherwise the built in rate limiting checks are if enabled allows for interception of redirect as a string mapping parameter names to values & $type
Definition: hooks.txt:2342
static & makeTitle($ns, $title, $fragment= '', $interwiki= '')
Create a new Title from a namespace index and a DB key.
Definition: Title.php:524
array $mInterwikis
2-D map of (prefix => DBK => 1)
Definition: LinksUpdate.php:59
Allows to change the fields on the form that will be generated $name
Definition: hooks.txt:314