MediaWiki  1.23.8
Go to the documentation of this file.
1 <?php
31 class RefreshLinksJob2 extends Job {
32  function __construct( $title, $params ) {
33  parent::__construct( 'refreshLinks2', $title, $params );
34  // Base jobs for large templates can easily be de-duplicated
35  $this->removeDuplicates = !isset( $params['start'] ) && !isset( $params['end'] );
36  }
42  function run() {
43  global $wgUpdateRowsPerJob;
45  $linkCache = LinkCache::singleton();
46  $linkCache->clear();
48  if ( is_null( $this->title ) ) {
49  $this->error = "refreshLinks2: Invalid title";
50  return false;
51  }
53  // Back compat for pre-r94435 jobs
54  $table = isset( $this->params['table'] ) ? $this->params['table'] : 'templatelinks';
56  // Avoid slave lag when fetching templates.
57  // When the outermost job is run, we know that the caller that enqueued it must have
58  // committed the relevant changes to the DB by now. At that point, record the master
59  // position and pass it along as the job recursively breaks into smaller range jobs.
60  // Hopefully, when leaf jobs are popped, the slaves will have reached that position.
61  if ( isset( $this->params['masterPos'] ) ) {
62  $masterPos = $this->params['masterPos'];
63  } elseif ( wfGetLB()->getServerCount() > 1 ) {
64  $masterPos = wfGetLB()->getMasterPos();
65  } else {
66  $masterPos = false;
67  }
69  $tbc = $this->title->getBacklinkCache();
71  $jobs = array(); // jobs to insert
72  if ( isset( $this->params['start'] ) && isset( $this->params['end'] ) ) {
73  # This is a partition job to trigger the insertion of leaf jobs...
74  $jobs = array_merge( $jobs, $this->getSingleTitleJobs( $table, $masterPos ) );
75  } else {
76  # This is a base job to trigger the insertion of partitioned jobs...
77  if ( $tbc->getNumLinks( $table, $wgUpdateRowsPerJob + 1 ) <= $wgUpdateRowsPerJob ) {
78  # Just directly insert the single per-title jobs
79  $jobs = array_merge( $jobs, $this->getSingleTitleJobs( $table, $masterPos ) );
80  } else {
81  # Insert the partition jobs to make per-title jobs
82  foreach ( $tbc->partition( $table, $wgUpdateRowsPerJob ) as $batch ) {
83  list( $start, $end ) = $batch;
84  $jobs[] = new RefreshLinksJob2( $this->title,
85  array(
86  'table' => $table,
87  'start' => $start,
88  'end' => $end,
89  'masterPos' => $masterPos,
90  ) + $this->getRootJobParams() // carry over information for de-duplication
91  );
92  }
93  }
94  }
96  if ( count( $jobs ) ) {
97  JobQueueGroup::singleton()->push( $jobs );
98  }
100  return true;
101  }
108  protected function getSingleTitleJobs( $table, $masterPos ) {
109  # The "start"/"end" fields are not set for the base jobs
110  $start = isset( $this->params['start'] ) ? $this->params['start'] : false;
111  $end = isset( $this->params['end'] ) ? $this->params['end'] : false;
112  $titles = $this->title->getBacklinkCache()->getLinks( $table, $start, $end );
113  # Convert into single page refresh links jobs.
114  # This handles well when in sapi mode and is useful in any case for job
115  # de-duplication. If many pages use template A, and that template itself
116  # uses template B, then an edit to both will create many duplicate jobs.
117  # Roughly speaking, for each page, one of the "RefreshLinksJob" jobs will
118  # get run first, and when it does, it will remove the duplicates. Of course,
119  # one page could have its job popped when the other page's job is still
120  # buried within the logic of a refreshLinks2 job.
121  $jobs = array();
122  foreach ( $titles as $title ) {
123  $jobs[] = new RefreshLinksJob( $title,
124  array( 'masterPos' => $masterPos ) + $this->getRootJobParams()
125  ); // carry over information for de-duplication
126  }
127  return $jobs;
128  }
133  public function getDeduplicationInfo() {
134  $info = parent::getDeduplicationInfo();
135  // Don't let highly unique "masterPos" values ruin duplicate detection
136  if ( is_array( $info['params'] ) ) {
137  unset( $info['params']['masterPos'] );
138  }
139  return $info;
140  }
141 }
Definition: Job.php:251
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
wfGetLB( $wiki=false)
Get a load balancer object.
Definition: GlobalFunctions.php:3669
Title $title
Definition: Job.php:38
Background job to update links for titles in certain backlink range by page ID.
Definition: RefreshLinksJob2.php:31
getSingleTitleJobs( $table, $masterPos)
Definition: RefreshLinksJob2.php:108
to move a page</td >< td > &*You are moving the page across *A non empty talk page already exists under the new or *You uncheck the box below In those you will have to move or merge the page manually if desired</td >< td > be sure to &You are responsible for making sure that links continue to point where they are supposed to go Note that the page will &a page at the new title
Definition: All_system_messages.txt:2703
Class to both describe a background job and handle jobs.
Definition: Job.php:31
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
the array() calling protocol came about after MediaWiki 1.4rc1.
List of Api Query prop modules.
when a variable name is used in a it is silently declared as a new masking the global
Definition: design.txt:93
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
Job to update link tables for pages.
Definition: RefreshLinksJob.php:37
array bool $params
Array of job parameters or false if none *.
Definition: Job.php:34
Run a refreshLinks2 job.
Definition: RefreshLinksJob2.php:42
Definition: RefreshLinksJob2.php:133
static singleton( $wiki=false)
Definition: JobQueueGroup.php:61
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
__construct( $title, $params)
Definition: RefreshLinksJob2.php:32
Definition: linkcache.txt:23
static & singleton()
Get an instance of this class.
Definition: LinkCache.php:49