/** * Opportunistically enqueue link update jobs given fresh parser output if useful * * @param ParserOutput $parserOutput Current version page output * @since 1.25 */ public function triggerOpportunisticLinksUpdate(ParserOutput $parserOutput) { if (wfReadOnly()) { return; } if (!Hooks::run('OpportunisticLinksUpdate', [$this, $this->mTitle, $parserOutput])) { return; } $config = RequestContext::getMain()->getConfig(); $params = ['isOpportunistic' => true, 'rootJobTimestamp' => $parserOutput->getCacheTime()]; if ($this->mTitle->areRestrictionsCascading()) { // If the page is cascade protecting, the links should really be up-to-date JobQueueGroup::singleton()->lazyPush(RefreshLinksJob::newPrioritized($this->mTitle, $params)); } elseif (!$config->get('MiserMode') && $parserOutput->hasDynamicContent()) { // Assume the output contains "dynamic" time/random based magic words. // Only update pages that expired due to dynamic content and NOT due to edits // to referenced templates/files. When the cache expires due to dynamic content, // page_touched is unchanged. We want to avoid triggering redundant jobs due to // views of pages that were just purged via HTMLCacheUpdateJob. In that case, the // template/file edit already triggered recursive RefreshLinksJob jobs. if ($this->getLinksTimestamp() > $this->getTouched()) { // If a page is uncacheable, do not keep spamming a job for it. // Although it would be de-duplicated, it would still waste I/O. $cache = ObjectCache::getLocalClusterInstance(); $key = $cache->makeKey('dynamic-linksupdate', 'last', $this->getId()); $ttl = max($parserOutput->getCacheExpiry(), 3600); if ($cache->add($key, time(), $ttl)) { JobQueueGroup::singleton()->lazyPush(RefreshLinksJob::newDynamic($this->mTitle, $params)); } } } }
/** * Queue recursive jobs for this page * * Which means do LinksUpdate on all pages that include the current page, * using the job queue. */ protected function queueRecursiveJobs() { self::queueRecursiveJobsForTable($this->mTitle, 'templatelinks'); if ($this->mTitle->getNamespace() == NS_FILE) { // Process imagelinks in case the title is or was a redirect self::queueRecursiveJobsForTable($this->mTitle, 'imagelinks'); } $bc = $this->mTitle->getBacklinkCache(); // Get jobs for cascade-protected backlinks for a high priority queue. // If meta-templates change to using a new template, the new template // should be implicitly protected as soon as possible, if applicable. // These jobs duplicate a subset of the above ones, but can run sooner. // Which ever runs first generally no-ops the other one. $jobs = array(); foreach ($bc->getCascadeProtectedLinks() as $title) { $jobs[] = RefreshLinksJob::newPrioritized($title, array()); } JobQueueGroup::singleton()->push($jobs); }