MediaWiki  1.23.12
LinksUpdate.php
Go to the documentation of this file.
1 <?php
28 class LinksUpdate extends SqlDataUpdate {
29  // @todo make members protected, but make sure extensions don't break
30 
32  public $mId;
33 
35  public $mTitle;
36 
38  public $mParserOutput;
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 $mProperties;
60 
62  public $mDb;
63 
65  public $mOptions;
66 
68  public $mRecursive;
69 
73  private $linkInsertions = null;
74 
78  private $linkDeletions = null;
79 
88  function __construct( $title, $parserOutput, $recursive = true ) {
89  parent::__construct( false ); // no implicit transaction
90 
91  if ( !( $title instanceof Title ) ) {
92  throw new MWException( "The calling convention to LinksUpdate::LinksUpdate() has changed. " .
93  "Please see Article::editUpdates() for an invocation example.\n" );
94  }
95 
96  if ( !( $parserOutput instanceof ParserOutput ) ) {
97  throw new MWException( "The calling convention to LinksUpdate::__construct() has changed. " .
98  "Please see WikiPage::doEditUpdates() for an invocation example.\n" );
99  }
100 
101  $this->mTitle = $title;
102  $this->mId = $title->getArticleID();
103 
104  if ( !$this->mId ) {
105  throw new MWException( "The Title object did not provide an article " .
106  "ID. Perhaps the page doesn't exist?" );
107  }
108 
109  $this->mParserOutput = $parserOutput;
110 
111  $this->mLinks = $parserOutput->getLinks();
112  $this->mImages = $parserOutput->getImages();
113  $this->mTemplates = $parserOutput->getTemplates();
114  $this->mExternals = $parserOutput->getExternalLinks();
115  $this->mCategories = $parserOutput->getCategories();
116  $this->mProperties = $parserOutput->getProperties();
117  $this->mInterwikis = $parserOutput->getInterwikiLinks();
118 
119  # Convert the format of the interlanguage links
120  # I didn't want to change it in the ParserOutput, because that array is passed all
121  # the way back to the skin, so either a skin API break would be required, or an
122  # inefficient back-conversion.
123  $ill = $parserOutput->getLanguageLinks();
124  $this->mInterlangs = array();
125  foreach ( $ill as $link ) {
126  list( $key, $title ) = explode( ':', $link, 2 );
127  $this->mInterlangs[$key] = $title;
128  }
129 
130  foreach ( $this->mCategories as &$sortkey ) {
131  # If the sortkey is longer then 255 bytes,
132  # it truncated by DB, and then doesn't get
133  # matched when comparing existing vs current
134  # categories, causing bug 25254.
135  # Also. substr behaves weird when given "".
136  if ( $sortkey !== '' ) {
137  $sortkey = substr( $sortkey, 0, 255 );
138  }
139  }
140 
141  $this->mRecursive = $recursive;
142 
143  wfRunHooks( 'LinksUpdateConstructed', array( &$this ) );
144  }
145 
149  public function doUpdate() {
150  wfRunHooks( 'LinksUpdate', array( &$this ) );
151  $this->doIncrementalUpdate();
152  wfRunHooks( 'LinksUpdateComplete', array( &$this ) );
153  }
154 
155  protected function doIncrementalUpdate() {
156  wfProfileIn( __METHOD__ );
157 
158  # Page links
159  $existing = $this->getExistingLinks();
160  $this->linkDeletions = $this->getLinkDeletions( $existing );
161  $this->linkInsertions = $this->getLinkInsertions( $existing );
162  $this->incrTableUpdate( 'pagelinks', 'pl', $this->linkDeletions, $this->linkInsertions );
163 
164  # Image links
165  $existing = $this->getExistingImages();
166 
167  $imageDeletes = $this->getImageDeletions( $existing );
168  $this->incrTableUpdate( 'imagelinks', 'il', $imageDeletes,
169  $this->getImageInsertions( $existing ) );
170 
171  # Invalidate all image description pages which had links added or removed
172  $imageUpdates = $imageDeletes + array_diff_key( $this->mImages, $existing );
173  $this->invalidateImageDescriptions( $imageUpdates );
174 
175  # External links
176  $existing = $this->getExistingExternals();
177  $this->incrTableUpdate( 'externallinks', 'el', $this->getExternalDeletions( $existing ),
178  $this->getExternalInsertions( $existing ) );
179 
180  # Language links
181  $existing = $this->getExistingInterlangs();
182  $this->incrTableUpdate( 'langlinks', 'll', $this->getInterlangDeletions( $existing ),
183  $this->getInterlangInsertions( $existing ) );
184 
185  # Inline interwiki links
186  $existing = $this->getExistingInterwikis();
187  $this->incrTableUpdate( 'iwlinks', 'iwl', $this->getInterwikiDeletions( $existing ),
188  $this->getInterwikiInsertions( $existing ) );
189 
190  # Template links
191  $existing = $this->getExistingTemplates();
192  $this->incrTableUpdate( 'templatelinks', 'tl', $this->getTemplateDeletions( $existing ),
193  $this->getTemplateInsertions( $existing ) );
194 
195  # Category links
196  $existing = $this->getExistingCategories();
197 
198  $categoryDeletes = $this->getCategoryDeletions( $existing );
199 
200  $this->incrTableUpdate( 'categorylinks', 'cl', $categoryDeletes,
201  $this->getCategoryInsertions( $existing ) );
202 
203  # Invalidate all categories which were added, deleted or changed (set symmetric difference)
204  $categoryInserts = array_diff_assoc( $this->mCategories, $existing );
205  $categoryUpdates = $categoryInserts + $categoryDeletes;
206  $this->invalidateCategories( $categoryUpdates );
207  $this->updateCategoryCounts( $categoryInserts, $categoryDeletes );
208 
209  # Page properties
210  $existing = $this->getExistingProperties();
211 
212  $propertiesDeletes = $this->getPropertyDeletions( $existing );
213 
214  $this->incrTableUpdate( 'page_props', 'pp', $propertiesDeletes,
215  $this->getPropertyInsertions( $existing ) );
216 
217  # Invalidate the necessary pages
218  $changed = $propertiesDeletes + array_diff_assoc( $this->mProperties, $existing );
219  $this->invalidateProperties( $changed );
220 
221  # Update the links table freshness for this title
222  $this->updateLinksTimestamp();
223 
224  # Refresh links of all pages including this page
225  # This will be in a separate transaction
226  if ( $this->mRecursive ) {
227  $this->queueRecursiveJobs();
228  }
229 
230  wfProfileOut( __METHOD__ );
231  }
232 
239  function queueRecursiveJobs() {
240  self::queueRecursiveJobsForTable( $this->mTitle, 'templatelinks' );
241  if ( $this->mTitle->getNamespace() == NS_FILE ) {
242  // Process imagelinks in case the title is or was a redirect
243  self::queueRecursiveJobsForTable( $this->mTitle, 'imagelinks' );
244  }
245  }
246 
253  public static function queueRecursiveJobsForTable( Title $title, $table ) {
254  wfProfileIn( __METHOD__ );
255  if ( $title->getBacklinkCache()->hasLinks( $table ) ) {
256  $job = new RefreshLinksJob(
257  $title,
258  array(
259  'table' => $table,
260  'recursive' => true,
261  ) + Job::newRootJobParams( // "overall" refresh links job info
262  "refreshlinks:{$table}:{$title->getPrefixedText()}"
263  )
264  );
265  JobQueueGroup::singleton()->push( $job );
266  JobQueueGroup::singleton()->deduplicateRootJob( $job );
267  }
268  wfProfileOut( __METHOD__ );
269  }
270 
274  function invalidateCategories( $cats ) {
275  $this->invalidatePages( NS_CATEGORY, array_keys( $cats ) );
276  }
277 
283  function updateCategoryCounts( $added, $deleted ) {
284  $a = WikiPage::factory( $this->mTitle );
285  $a->updateCategoryCounts(
286  array_keys( $added ), array_keys( $deleted )
287  );
288  }
289 
293  function invalidateImageDescriptions( $images ) {
294  $this->invalidatePages( NS_FILE, array_keys( $images ) );
295  }
296 
304  function incrTableUpdate( $table, $prefix, $deletions, $insertions ) {
305  if ( $table == 'page_props' ) {
306  $fromField = 'pp_page';
307  } else {
308  $fromField = "{$prefix}_from";
309  }
310  $where = array( $fromField => $this->mId );
311  if ( $table == 'pagelinks' || $table == 'templatelinks' || $table == 'iwlinks' ) {
312  if ( $table == 'iwlinks' ) {
313  $baseKey = 'iwl_prefix';
314  } else {
315  $baseKey = "{$prefix}_namespace";
316  }
317  $clause = $this->mDb->makeWhereFrom2d( $deletions, $baseKey, "{$prefix}_title" );
318  if ( $clause ) {
319  $where[] = $clause;
320  } else {
321  $where = false;
322  }
323  } else {
324  if ( $table == 'langlinks' ) {
325  $toField = 'll_lang';
326  } elseif ( $table == 'page_props' ) {
327  $toField = 'pp_propname';
328  } else {
329  $toField = $prefix . '_to';
330  }
331  if ( count( $deletions ) ) {
332  $where[$toField] = array_keys( $deletions );
333  } else {
334  $where = false;
335  }
336  }
337  if ( $where ) {
338  $this->mDb->delete( $table, $where, __METHOD__ );
339  }
340  if ( count( $insertions ) ) {
341  $this->mDb->insert( $table, $insertions, __METHOD__, 'IGNORE' );
342  wfRunHooks( 'LinksUpdateAfterInsert', array( $this, $table, $insertions ) );
343  }
344  }
345 
352  private function getLinkInsertions( $existing = array() ) {
353  $arr = array();
354  foreach ( $this->mLinks as $ns => $dbkeys ) {
355  $diffs = isset( $existing[$ns] )
356  ? array_diff_key( $dbkeys, $existing[$ns] )
357  : $dbkeys;
358  foreach ( $diffs as $dbk => $id ) {
359  $arr[] = array(
360  'pl_from' => $this->mId,
361  'pl_namespace' => $ns,
362  'pl_title' => $dbk
363  );
364  }
365  }
366 
367  return $arr;
368  }
369 
375  private function getTemplateInsertions( $existing = array() ) {
376  $arr = array();
377  foreach ( $this->mTemplates as $ns => $dbkeys ) {
378  $diffs = isset( $existing[$ns] ) ? array_diff_key( $dbkeys, $existing[$ns] ) : $dbkeys;
379  foreach ( $diffs as $dbk => $id ) {
380  $arr[] = array(
381  'tl_from' => $this->mId,
382  'tl_namespace' => $ns,
383  'tl_title' => $dbk
384  );
385  }
386  }
387 
388  return $arr;
389  }
390 
397  private function getImageInsertions( $existing = array() ) {
398  $arr = array();
399  $diffs = array_diff_key( $this->mImages, $existing );
400  foreach ( $diffs as $iname => $dummy ) {
401  $arr[] = array(
402  'il_from' => $this->mId,
403  'il_to' => $iname
404  );
405  }
406 
407  return $arr;
408  }
409 
415  private function getExternalInsertions( $existing = array() ) {
416  $arr = array();
417  $diffs = array_diff_key( $this->mExternals, $existing );
418  foreach ( $diffs as $url => $dummy ) {
419  foreach ( wfMakeUrlIndexes( $url ) as $index ) {
420  $arr[] = array(
421  'el_id' => $this->mDb->nextSequenceValue( 'externallinks_el_id_seq' ),
422  'el_from' => $this->mId,
423  'el_to' => $url,
424  'el_index' => $index,
425  );
426  }
427  }
428 
429  return $arr;
430  }
431 
440  private function getCategoryInsertions( $existing = array() ) {
441  global $wgContLang, $wgCategoryCollation;
442  $diffs = array_diff_assoc( $this->mCategories, $existing );
443  $arr = array();
444  foreach ( $diffs as $name => $prefix ) {
446  $wgContLang->findVariantLink( $name, $nt, true );
447 
448  if ( $this->mTitle->getNamespace() == NS_CATEGORY ) {
449  $type = 'subcat';
450  } elseif ( $this->mTitle->getNamespace() == NS_FILE ) {
451  $type = 'file';
452  } else {
453  $type = 'page';
454  }
455 
456  # Treat custom sortkeys as a prefix, so that if multiple
457  # things are forced to sort as '*' or something, they'll
458  # sort properly in the category rather than in page_id
459  # order or such.
460  $sortkey = Collation::singleton()->getSortKey(
461  $this->mTitle->getCategorySortkey( $prefix ) );
462 
463  $arr[] = array(
464  'cl_from' => $this->mId,
465  'cl_to' => $name,
466  'cl_sortkey' => $sortkey,
467  'cl_timestamp' => $this->mDb->timestamp(),
468  'cl_sortkey_prefix' => $prefix,
469  'cl_collation' => $wgCategoryCollation,
470  'cl_type' => $type,
471  );
472  }
473 
474  return $arr;
475  }
476 
484  private function getInterlangInsertions( $existing = array() ) {
485  $diffs = array_diff_assoc( $this->mInterlangs, $existing );
486  $arr = array();
487  foreach ( $diffs as $lang => $title ) {
488  $arr[] = array(
489  'll_from' => $this->mId,
490  'll_lang' => $lang,
491  'll_title' => $title
492  );
493  }
494 
495  return $arr;
496  }
497 
503  function getPropertyInsertions( $existing = array() ) {
504  $diffs = array_diff_assoc( $this->mProperties, $existing );
505  $arr = array();
506  foreach ( $diffs as $name => $value ) {
507  $arr[] = array(
508  'pp_page' => $this->mId,
509  'pp_propname' => $name,
510  'pp_value' => $value,
511  );
512  }
513 
514  return $arr;
515  }
516 
523  private function getInterwikiInsertions( $existing = array() ) {
524  $arr = array();
525  foreach ( $this->mInterwikis as $prefix => $dbkeys ) {
526  $diffs = isset( $existing[$prefix] )
527  ? array_diff_key( $dbkeys, $existing[$prefix] )
528  : $dbkeys;
529 
530  foreach ( $diffs as $dbk => $id ) {
531  $arr[] = array(
532  'iwl_from' => $this->mId,
533  'iwl_prefix' => $prefix,
534  'iwl_title' => $dbk
535  );
536  }
537  }
538 
539  return $arr;
540  }
541 
548  private function getLinkDeletions( $existing ) {
549  $del = array();
550  foreach ( $existing as $ns => $dbkeys ) {
551  if ( isset( $this->mLinks[$ns] ) ) {
552  $del[$ns] = array_diff_key( $existing[$ns], $this->mLinks[$ns] );
553  } else {
554  $del[$ns] = $existing[$ns];
555  }
556  }
557 
558  return $del;
559  }
560 
567  private function getTemplateDeletions( $existing ) {
568  $del = array();
569  foreach ( $existing as $ns => $dbkeys ) {
570  if ( isset( $this->mTemplates[$ns] ) ) {
571  $del[$ns] = array_diff_key( $existing[$ns], $this->mTemplates[$ns] );
572  } else {
573  $del[$ns] = $existing[$ns];
574  }
575  }
576 
577  return $del;
578  }
579 
586  private function getImageDeletions( $existing ) {
587  return array_diff_key( $existing, $this->mImages );
588  }
589 
596  private function getExternalDeletions( $existing ) {
597  return array_diff_key( $existing, $this->mExternals );
598  }
599 
606  private function getCategoryDeletions( $existing ) {
607  return array_diff_assoc( $existing, $this->mCategories );
608  }
609 
616  private function getInterlangDeletions( $existing ) {
617  return array_diff_assoc( $existing, $this->mInterlangs );
618  }
619 
625  function getPropertyDeletions( $existing ) {
626  return array_diff_assoc( $existing, $this->mProperties );
627  }
628 
635  private function getInterwikiDeletions( $existing ) {
636  $del = array();
637  foreach ( $existing as $prefix => $dbkeys ) {
638  if ( isset( $this->mInterwikis[$prefix] ) ) {
639  $del[$prefix] = array_diff_key( $existing[$prefix], $this->mInterwikis[$prefix] );
640  } else {
641  $del[$prefix] = $existing[$prefix];
642  }
643  }
644 
645  return $del;
646  }
647 
653  private function getExistingLinks() {
654  $res = $this->mDb->select( 'pagelinks', array( 'pl_namespace', 'pl_title' ),
655  array( 'pl_from' => $this->mId ), __METHOD__, $this->mOptions );
656  $arr = array();
657  foreach ( $res as $row ) {
658  if ( !isset( $arr[$row->pl_namespace] ) ) {
659  $arr[$row->pl_namespace] = array();
660  }
661  $arr[$row->pl_namespace][$row->pl_title] = 1;
662  }
663 
664  return $arr;
665  }
666 
672  private function getExistingTemplates() {
673  $res = $this->mDb->select( 'templatelinks', array( 'tl_namespace', 'tl_title' ),
674  array( 'tl_from' => $this->mId ), __METHOD__, $this->mOptions );
675  $arr = array();
676  foreach ( $res as $row ) {
677  if ( !isset( $arr[$row->tl_namespace] ) ) {
678  $arr[$row->tl_namespace] = array();
679  }
680  $arr[$row->tl_namespace][$row->tl_title] = 1;
681  }
682 
683  return $arr;
684  }
685 
691  private function getExistingImages() {
692  $res = $this->mDb->select( 'imagelinks', array( 'il_to' ),
693  array( 'il_from' => $this->mId ), __METHOD__, $this->mOptions );
694  $arr = array();
695  foreach ( $res as $row ) {
696  $arr[$row->il_to] = 1;
697  }
698 
699  return $arr;
700  }
701 
707  private function getExistingExternals() {
708  $res = $this->mDb->select( 'externallinks', array( 'el_to' ),
709  array( 'el_from' => $this->mId ), __METHOD__, $this->mOptions );
710  $arr = array();
711  foreach ( $res as $row ) {
712  $arr[$row->el_to] = 1;
713  }
714 
715  return $arr;
716  }
717 
723  private function getExistingCategories() {
724  $res = $this->mDb->select( 'categorylinks', array( 'cl_to', 'cl_sortkey_prefix' ),
725  array( 'cl_from' => $this->mId ), __METHOD__, $this->mOptions );
726  $arr = array();
727  foreach ( $res as $row ) {
728  $arr[$row->cl_to] = $row->cl_sortkey_prefix;
729  }
730 
731  return $arr;
732  }
733 
740  private function getExistingInterlangs() {
741  $res = $this->mDb->select( 'langlinks', array( 'll_lang', 'll_title' ),
742  array( 'll_from' => $this->mId ), __METHOD__, $this->mOptions );
743  $arr = array();
744  foreach ( $res as $row ) {
745  $arr[$row->ll_lang] = $row->ll_title;
746  }
747 
748  return $arr;
749  }
750 
755  protected function getExistingInterwikis() {
756  $res = $this->mDb->select( 'iwlinks', array( 'iwl_prefix', 'iwl_title' ),
757  array( 'iwl_from' => $this->mId ), __METHOD__, $this->mOptions );
758  $arr = array();
759  foreach ( $res as $row ) {
760  if ( !isset( $arr[$row->iwl_prefix] ) ) {
761  $arr[$row->iwl_prefix] = array();
762  }
763  $arr[$row->iwl_prefix][$row->iwl_title] = 1;
764  }
765 
766  return $arr;
767  }
768 
774  private function getExistingProperties() {
775  $res = $this->mDb->select( 'page_props', array( 'pp_propname', 'pp_value' ),
776  array( 'pp_page' => $this->mId ), __METHOD__, $this->mOptions );
777  $arr = array();
778  foreach ( $res as $row ) {
779  $arr[$row->pp_propname] = $row->pp_value;
780  }
781 
782  return $arr;
783  }
784 
789  public function getTitle() {
790  return $this->mTitle;
791  }
792 
798  public function getParserOutput() {
800  }
801 
806  public function getImages() {
807  return $this->mImages;
808  }
809 
814  private function invalidateProperties( $changed ) {
815  global $wgPagePropLinkInvalidations;
816 
817  foreach ( $changed as $name => $value ) {
818  if ( isset( $wgPagePropLinkInvalidations[$name] ) ) {
819  $inv = $wgPagePropLinkInvalidations[$name];
820  if ( !is_array( $inv ) ) {
821  $inv = array( $inv );
822  }
823  foreach ( $inv as $table ) {
824  $update = new HTMLCacheUpdate( $this->mTitle, $table );
825  $update->doUpdate();
826  }
827  }
828  }
829  }
830 
836  public function getAddedLinks() {
837  if ( $this->linkInsertions === null ) {
838  return null;
839  }
840  $result = array();
841  foreach ( $this->linkInsertions as $insertion ) {
842  $result[] = Title::makeTitle( $insertion['pl_namespace'], $insertion['pl_title'] );
843  }
844 
845  return $result;
846  }
847 
853  public function getRemovedLinks() {
854  if ( $this->linkDeletions === null ) {
855  return null;
856  }
857  $result = array();
858  foreach ( $this->linkDeletions as $ns => $titles ) {
859  foreach ( $titles as $title => $unused ) {
860  $result[] = Title::makeTitle( $ns, $title );
861  }
862  }
863 
864  return $result;
865  }
866 
870  protected function updateLinksTimestamp() {
871  if ( $this->mId ) {
872  // The link updates made here only reflect the freshness of the parser output
873  $timestamp = $this->mParserOutput->getCacheTime();
874  $this->mDb->update( 'page',
875  array( 'page_links_updated' => $this->mDb->timestamp( $timestamp ) ),
876  array( 'page_id' => $this->mId ),
877  __METHOD__
878  );
879  }
880  }
881 }
882 
886 class LinksDeletionUpdate extends SqlDataUpdate {
888  protected $mPage;
889 
896  function __construct( WikiPage $page ) {
897  parent::__construct( false ); // no implicit transaction
898 
899  $this->mPage = $page;
900 
901  if ( !$page->exists() ) {
902  throw new MWException( "Page ID not known, perhaps the page doesn't exist?" );
903  }
904  }
905 
909  public function doUpdate() {
910  $title = $this->mPage->getTitle();
911  $id = $this->mPage->getId();
912 
913  # Delete restrictions for it
914  $this->mDb->delete( 'page_restrictions', array( 'pr_page' => $id ), __METHOD__ );
915 
916  # Fix category table counts
917  $cats = array();
918  $res = $this->mDb->select( 'categorylinks', 'cl_to', array( 'cl_from' => $id ), __METHOD__ );
919 
920  foreach ( $res as $row ) {
921  $cats[] = $row->cl_to;
922  }
923 
924  $this->mPage->updateCategoryCounts( array(), $cats );
925 
926  # If using cascading deletes, we can skip some explicit deletes
927  if ( !$this->mDb->cascadingDeletes() ) {
928  # Delete outgoing links
929  $this->mDb->delete( 'pagelinks', array( 'pl_from' => $id ), __METHOD__ );
930  $this->mDb->delete( 'imagelinks', array( 'il_from' => $id ), __METHOD__ );
931  $this->mDb->delete( 'categorylinks', array( 'cl_from' => $id ), __METHOD__ );
932  $this->mDb->delete( 'templatelinks', array( 'tl_from' => $id ), __METHOD__ );
933  $this->mDb->delete( 'externallinks', array( 'el_from' => $id ), __METHOD__ );
934  $this->mDb->delete( 'langlinks', array( 'll_from' => $id ), __METHOD__ );
935  $this->mDb->delete( 'iwlinks', array( 'iwl_from' => $id ), __METHOD__ );
936  $this->mDb->delete( 'redirect', array( 'rd_from' => $id ), __METHOD__ );
937  $this->mDb->delete( 'page_props', array( 'pp_page' => $id ), __METHOD__ );
938  }
939 
940  # If using cleanup triggers, we can skip some manual deletes
941  if ( !$this->mDb->cleanupTriggers() ) {
942  # Clean up recentchanges entries...
943  $this->mDb->delete( 'recentchanges',
944  array( 'rc_type != ' . RC_LOG,
945  'rc_namespace' => $title->getNamespace(),
946  'rc_title' => $title->getDBkey() ),
947  __METHOD__ );
948  $this->mDb->delete( 'recentchanges',
949  array( 'rc_type != ' . RC_LOG, 'rc_cur_id' => $id ),
950  __METHOD__ );
951  }
952  }
953 
959  function updateCategoryCounts( $added, $deleted ) {
960  $a = WikiPage::factory( $this->mTitle );
961  $a->updateCategoryCounts(
962  array_keys( $added ), array_keys( $deleted )
963  );
964  }
965 }
LinksUpdate\getInterlangInsertions
getInterlangInsertions( $existing=array())
Get an array of interlanguage link insertions.
Definition: LinksUpdate.php:469
LinksUpdate\getTemplateDeletions
getTemplateDeletions( $existing)
Given an array of existing templates, returns those templates which are not in $this and thus should ...
Definition: LinksUpdate.php:552
Title\makeTitle
static & makeTitle( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
Definition: Title.php:398
$result
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. $reader:XMLReader object $logInfo:Array of information Return false to stop further processing of the tag 'ImportHandlePageXMLTag':When parsing a XML tag in a page. $reader:XMLReader object $pageInfo:Array of information Return false to stop further processing of the tag 'ImportHandleRevisionXMLTag':When parsing a XML tag in a page revision. $reader:XMLReader object $pageInfo:Array of page information $revisionInfo:Array of revision information Return false to stop further processing of the tag 'ImportHandleToplevelXMLTag':When parsing a top level XML tag. $reader:XMLReader object Return false to stop further processing of the tag 'ImportHandleUploadXMLTag':When parsing a XML tag in a file upload. $reader:XMLReader object $revisionInfo:Array of information Return false to stop further processing of the tag '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 '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. '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 '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 '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 wfIsTrustedProxy() $ip:IP being check $result:Change this value to override the result of wfIsTrustedProxy() '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 User::isValidEmailAddr(), 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. '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 '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) '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. '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:1528
LinksUpdate\getCategoryDeletions
getCategoryDeletions( $existing)
Given an array of existing categories, returns those categories which are not in $this and thus shoul...
Definition: LinksUpdate.php:591
LinksUpdate\doUpdate
doUpdate()
Update link tables with outgoing links from an updated article.
Definition: LinksUpdate.php:134
ParserOutput
Definition: ParserOutput.php:24
php
skin txt MediaWiki includes four core it has been set as the default in MediaWiki since the replacing Monobook it had been been the default skin since before being replaced by Vector largely rewritten in while keeping its appearance Several legacy skins were removed in the as the burden of supporting them became too heavy to bear Those in etc for skin dependent CSS etc for skin dependent JavaScript These can also be customised on a per user by etc This feature has led to a wide variety of user styles becoming that gallery is a good place to ending in php
Definition: skin.txt:62
LinksUpdate\getInterwikiDeletions
getInterwikiDeletions( $existing)
Given an array of existing interwiki links, returns those links which are not in $this and thus shoul...
Definition: LinksUpdate.php:620
$timestamp
if( $limit) $timestamp
Definition: importImages.php:104
SqlDataUpdate\invalidatePages
invalidatePages( $namespace, array $dbkeys)
Invalidate the cache of a list of pages from a single namespace.
Definition: SqlDataUpdate.php:115
wfMakeUrlIndexes
wfMakeUrlIndexes( $url)
Make URL indexes, appropriate for the el_index field of externallinks.
Definition: GlobalFunctions.php:895
LinksUpdate\queueRecursiveJobsForTable
static queueRecursiveJobsForTable(Title $title, $table)
Queue a RefreshLinks job for any table.
Definition: LinksUpdate.php:238
wfProfileIn
wfProfileIn( $functionname)
Begin profiling of a function.
Definition: Profiler.php:33
LinksUpdate\$mId
int $mId
Page ID of the article linked from *.
Definition: LinksUpdate.php:31
RC_LOG
const RC_LOG
Definition: Defines.php:181
LinksUpdate\$mCategories
array $mCategories
Map of category names to sort keys *.
Definition: LinksUpdate.php:45
LinksDeletionUpdate\__construct
__construct(WikiPage $page)
Constructor.
Definition: LinksUpdate.php:880
WikiPage
Class representing a MediaWiki article and history.
Definition: WikiPage.php:37
LinksUpdate
See docs/deferred.txt.
Definition: LinksUpdate.php:28
NS_FILE
const NS_FILE
Definition: Defines.php:85
LinksUpdate\$mImages
array $mImages
DB keys of the images used, in the array key only *.
Definition: LinksUpdate.php:39
$wgContLang
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 content language as $wgContLang
Definition: design.txt:56
LinksUpdate\getImageDeletions
getImageDeletions( $existing)
Given an array of existing images, returns those images which are not in $this and thus should be del...
Definition: LinksUpdate.php:571
LinksUpdate\invalidateImageDescriptions
invalidateImageDescriptions( $images)
Definition: LinksUpdate.php:278
$link
set to $title object and return false for a match for latest after cache objects are set use the ContentHandler facility to handle CSS and JavaScript for highlighting & $link
Definition: hooks.txt:2154
LinksUpdate\updateLinksTimestamp
updateLinksTimestamp()
Update links table freshness.
Definition: LinksUpdate.php:855
LinksUpdate\getExternalDeletions
getExternalDeletions( $existing)
Given an array of existing external links, returns those links which are not in $this and thus should...
Definition: LinksUpdate.php:581
LinksUpdate\getPropertyInsertions
getPropertyInsertions( $existing=array())
Get an array of page property insertions.
Definition: LinksUpdate.php:488
LinksUpdate\queueRecursiveJobs
queueRecursiveJobs()
Queue recursive jobs for this page.
Definition: LinksUpdate.php:224
LinksUpdate\getExistingImages
getExistingImages()
Get an array of existing images, image names in the keys.
Definition: LinksUpdate.php:676
LinksUpdate\incrTableUpdate
incrTableUpdate( $table, $prefix, $deletions, $insertions)
Update a table by doing a delete query then an insert query.
Definition: LinksUpdate.php:289
Collation\singleton
static singleton()
Definition: Collation.php:29
LinksUpdate\getExistingTemplates
getExistingTemplates()
Get an array of existing templates, as a 2-D array.
Definition: LinksUpdate.php:657
MWException
MediaWiki exception.
Definition: MWException.php:26
WikiPage\factory
static factory(Title $title)
Create a WikiPage object of the appropriate class for the given title.
Definition: WikiPage.php:103
LinksUpdate\$mTemplates
array $mTemplates
Map of title strings to IDs for the template references, including broken ones *.
Definition: LinksUpdate.php:41
LinksUpdate\doIncrementalUpdate
doIncrementalUpdate()
Definition: LinksUpdate.php:140
LinksUpdate\$mProperties
array $mProperties
Map of arbitrary name to value *.
Definition: LinksUpdate.php:49
$titles
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
LinksUpdate\getInterlangDeletions
getInterlangDeletions( $existing)
Given an array of existing interlanguage links, returns those links which are not in $this and thus s...
Definition: LinksUpdate.php:601
LinksDeletionUpdate\$mPage
WikiPage $mPage
The WikiPage that was deleted *.
Definition: LinksUpdate.php:872
LinksUpdate\invalidateProperties
invalidateProperties( $changed)
Invalidate any necessary link lists related to page property changes.
Definition: LinksUpdate.php:799
wfProfileOut
wfProfileOut( $functionname='missing')
Stop profiling of a function.
Definition: Profiler.php:46
WikiPage\exists
exists()
Definition: WikiPage.php:448
wfRunHooks
wfRunHooks( $event, array $args=array(), $deprecatedVersion=null)
Call hook functions defined in $wgHooks.
Definition: GlobalFunctions.php:4058
LinksUpdate\getImageInsertions
getImageInsertions( $existing=array())
Get an array of image insertions Skips the names specified in $existing.
Definition: LinksUpdate.php:382
LinksUpdate\$linkInsertions
null array $linkInsertions
Added links if calculated.
Definition: LinksUpdate.php:59
array
the array() calling protocol came about after MediaWiki 1.4rc1.
List of Api Query prop modules.
global
when a variable name is used in a it is silently declared as a new masking the global
Definition: design.txt:93
NS_CATEGORY
const NS_CATEGORY
Definition: Defines.php:93
LinksUpdate\__construct
__construct( $title, $parserOutput, $recursive=true)
Constructor.
Definition: LinksUpdate.php:73
LinksUpdate\getExistingProperties
getExistingProperties()
Get an array of existing categories, with the name in the key and sort key in the value.
Definition: LinksUpdate.php:759
LinksUpdate\$mTitle
Title $mTitle
object of the article linked from *
Definition: LinksUpdate.php:33
LinksUpdate\getTitle
getTitle()
Return the title object of the page being updated.
Definition: LinksUpdate.php:774
Job\newRootJobParams
static newRootJobParams( $key)
Definition: Job.php:239
list
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
LinksUpdate\getExistingInterlangs
getExistingInterlangs()
Get an array of existing interlanguage links, with the language code in the key and the title in the ...
Definition: LinksUpdate.php:725
LinksUpdate\$mParserOutput
ParserOutput $mParserOutput
Definition: LinksUpdate.php:35
LinksUpdate\getParserOutput
getParserOutput()
Returns parser output.
Definition: LinksUpdate.php:783
LinksDeletionUpdate\doUpdate
doUpdate()
Do some database updates after deletion.
Definition: LinksUpdate.php:893
HTMLCacheUpdate
Class to invalidate the HTML cache of all the pages linking to a given title.
Definition: HTMLCacheUpdate.php:29
LinksUpdate\getAddedLinks
getAddedLinks()
Fetch page links added by this LinksUpdate.
Definition: LinksUpdate.php:821
Title\makeTitleSafe
static makeTitleSafe( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
Definition: Title.php:422
LinksUpdate\$mDb
DatabaseBase $mDb
Database connection reference *.
Definition: LinksUpdate.php:51
RefreshLinksJob
Job to update link tables for pages.
Definition: RefreshLinksJob.php:37
$title
presenting them properly to the user as errors is done by the caller $title
Definition: hooks.txt:1324
$name
Allows to change the fields on the form that will be generated $name
Definition: hooks.txt:336
$value
$value
Definition: styleTest.css.php:45
LinksUpdate\getTemplateInsertions
getTemplateInsertions( $existing=array())
Get an array of template insertions.
Definition: LinksUpdate.php:360
LinksUpdate\$mOptions
array $mOptions
SELECT options to be used *.
Definition: LinksUpdate.php:53
DatabaseBase
Database abstraction object.
Definition: Database.php:219
LinksUpdate\getLinkInsertions
getLinkInsertions( $existing=array())
Get an array of pagelinks insertions for passing to the DB Skips the titles specified by the 2-D arra...
Definition: LinksUpdate.php:337
LinksUpdate\getExistingCategories
getExistingCategories()
Get an array of existing categories, with the name in the key and sort key in the value.
Definition: LinksUpdate.php:708
LinksUpdate\$linkDeletions
null array $linkDeletions
Deleted links if calculated.
Definition: LinksUpdate.php:63
LinksDeletionUpdate
Update object handling the cleanup of links tables after a page was deleted.
Definition: LinksUpdate.php:871
SqlDataUpdate
Abstract base class for update jobs that put some secondary data extracted from article content into ...
Definition: SqlDataUpdate.php:33
LinksUpdate\getExistingExternals
getExistingExternals()
Get an array of existing external links, URLs in the keys.
Definition: LinksUpdate.php:692
LinksUpdate\getPropertyDeletions
getPropertyDeletions( $existing)
Get array of properties which should be deleted.
Definition: LinksUpdate.php:610
LinksUpdate\getInterwikiInsertions
getInterwikiInsertions( $existing=array())
Get an array of interwiki insertions for passing to the DB Skips the titles specified by the 2-D arra...
Definition: LinksUpdate.php:508
DataUpdate\__construct
__construct()
Constructor.
Definition: DataUpdate.php:36
LinksUpdate\getImages
getImages()
Return the list of images used as generated by the parser.
Definition: LinksUpdate.php:791
LinksUpdate\$mInterlangs
array $mInterlangs
ap of language codes to titles *
Definition: LinksUpdate.php:47
LinksUpdate\getCategoryInsertions
getCategoryInsertions( $existing=array())
Get an array of category insertions.
Definition: LinksUpdate.php:425
Title
Represents a title within MediaWiki.
Definition: Title.php:35
LinksUpdate\updateCategoryCounts
updateCategoryCounts( $added, $deleted)
Update all the appropriate counts in the category table.
Definition: LinksUpdate.php:268
LinksUpdate\getRemovedLinks
getRemovedLinks()
Fetch page links removed by this LinksUpdate.
Definition: LinksUpdate.php:838
LinksUpdate\$mExternals
array $mExternals
URLs of external links, array key only *.
Definition: LinksUpdate.php:43
$job
if(count( $args)< 1) $job
Definition: recompressTracked.php:42
JobQueueGroup\singleton
static singleton( $wiki=false)
Definition: JobQueueGroup.php:61
as
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
LinksUpdate\$mRecursive
bool $mRecursive
Whether to queue jobs for recursive updates *.
Definition: LinksUpdate.php:55
LinksUpdate\getExternalInsertions
getExternalInsertions( $existing=array())
Get an array of externallinks insertions.
Definition: LinksUpdate.php:400
LinksUpdate\invalidateCategories
invalidateCategories( $cats)
Definition: LinksUpdate.php:259
LinksUpdate\getExistingLinks
getExistingLinks()
Get an array of existing links, as a 2-D array.
Definition: LinksUpdate.php:638
$res
$res
Definition: database.txt:21
LinksUpdate\$mLinks
array $mLinks
Map of title strings to IDs for the links in the document *.
Definition: LinksUpdate.php:37
LinksUpdate\getLinkDeletions
getLinkDeletions( $existing)
Given an array of existing links, returns those links which are not in $this and thus should be delet...
Definition: LinksUpdate.php:533
LinksDeletionUpdate\updateCategoryCounts
updateCategoryCounts( $added, $deleted)
Update all the appropriate counts in the category table.
Definition: LinksUpdate.php:943
$changed
$changed
Definition: UtfNormalGenerate.php:130
LinksUpdate\getExistingInterwikis
getExistingInterwikis()
Get an array of existing inline interwiki links, as a 2-D array.
Definition: LinksUpdate.php:740
$type
$type
Definition: testCompression.php:46