/** * 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', array($this, $this->mTitle, $parserOutput))) { return; } if ($this->mTitle->areRestrictionsCascading()) { // If the page is cascade protecting, the links should really be up-to-date $params = array('prioritize' => true); } elseif ($parserOutput->hasDynamicContent()) { // Assume the output contains time/random based magic words $params = array(); } else { // If the inclusions are deterministic, the edit-triggered link jobs are enough return; } // Check if the last link refresh was before page_touched if ($this->getLinksTimestamp() < $this->getTouched()) { $params['isOpportunistic'] = true; $params['rootJobTimestamp'] = $parserOutput->getCacheTime(); JobQueueGroup::singleton()->lazyPush(EnqueueJob::newFromLocalJobs(new JobSpecification('refreshLinks', $params, array('removeDuplicates' => true), $this->mTitle))); } }
/** * Reset the notification timestamp of this entry * * @param bool $force Whether to force the write query to be executed even if the * page is not watched or the notification timestamp is already NULL. * @param int $oldid The revision id being viewed. If not given or 0, latest revision is assumed. * @mode int $mode WatchedItem::DEFERRED/IMMEDIATE */ public function resetNotificationTimestamp($force = '', $oldid = 0, $mode = self::IMMEDIATE) { global $wgActivityUpdatesUseJobQueue; // Only loggedin user can have a watchlist if (wfReadOnly() || $this->mUser->isAnon() || !$this->isAllowed('editmywatchlist')) { return; } if ($force != 'force') { $this->load(); if (!$this->watched || $this->timestamp === null) { return; } } $title = $this->getTitle(); if (!$oldid) { // No oldid given, assuming latest revision; clear the timestamp. $notificationTimestamp = null; } elseif (!$title->getNextRevisionID($oldid)) { // Oldid given and is the latest revision for this title; clear the timestamp. $notificationTimestamp = null; } else { // See if the version marked as read is more recent than the one we're viewing. // Call load() if it wasn't called before due to $force. $this->load(); if ($this->timestamp === null) { // This can only happen if $force is enabled. $notificationTimestamp = null; } else { // Oldid given and isn't the latest; update the timestamp. // This will result in no further notification emails being sent! $notificationTimestamp = Revision::getTimestampFromId($title, $oldid); // We need to go one second to the future because of various strict comparisons // throughout the codebase $ts = new MWTimestamp($notificationTimestamp); $ts->timestamp->add(new DateInterval('PT1S')); $notificationTimestamp = $ts->getTimestamp(TS_MW); if ($notificationTimestamp < $this->timestamp) { if ($force != 'force') { return; } else { // This is a little silly… $notificationTimestamp = $this->timestamp; } } } } // If the page is watched by the user (or may be watched), update the timestamp if ($mode === self::DEFERRED && $wgActivityUpdatesUseJobQueue) { JobQueueGroup::singleton()->push(EnqueueJob::newFromLocalJobs(new JobSpecification('activityUpdateJob', array('type' => 'updateWatchlistNotification', 'userid' => $this->getUserId(), 'notifTime' => $notificationTimestamp, 'curTime' => time()), array('removeDuplicates' => true), $title))); } else { $dbw = wfGetDB(DB_MASTER); $dbw->update('watchlist', array('wl_notificationtimestamp' => $notificationTimestamp), $this->dbCond(), __METHOD__); } $this->timestamp = null; }