X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fjobqueue%2Fjobs%2FRefreshLinksJob.php;h=02bb829e1ae42f7ea8e07d40643e74ee9b399f21;hb=1e90c794e5c96153f92452f35ca7a639f24682d5;hp=64d955ae96088b2ffeabc38361a7e69dcf393f85;hpb=15c5de3553ad2a07dac155fde59f0585c834d203;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/jobqueue/jobs/RefreshLinksJob.php b/includes/jobqueue/jobs/RefreshLinksJob.php index 64d955ae96..51e964d54f 100644 --- a/includes/jobqueue/jobs/RefreshLinksJob.php +++ b/includes/jobqueue/jobs/RefreshLinksJob.php @@ -39,9 +39,9 @@ use Wikimedia\Rdbms\DBReplicationWaitError; class RefreshLinksJob extends Job { /** @var float Cache parser output when it takes this long to render */ const PARSE_THRESHOLD_SEC = 1.0; - /** @var integer Lag safety margin when comparing root job times to last-refresh times */ + /** @var int Lag safety margin when comparing root job times to last-refresh times */ const CLOCK_FUDGE = 10; - /** @var integer How many seconds to wait for replica DBs to catch up */ + /** @var int How many seconds to wait for replica DBs to catch up */ const LAG_WAIT_TIMEOUT = 15; function __construct( Title $title, array $params ) { @@ -87,7 +87,7 @@ class RefreshLinksJob extends Job { // When the base job branches, wait for the replica DBs to catch up to the master. // From then on, we know that any template changes at the time the base job was // enqueued will be reflected in backlink page parses when the leaf jobs run. - if ( !isset( $params['range'] ) ) { + if ( !isset( $this->params['range'] ) ) { try { $lbFactory = MediaWikiServices::getInstance()->getDBLoadBalancerFactory(); $lbFactory->waitForReplication( [ @@ -113,7 +113,7 @@ class RefreshLinksJob extends Job { JobQueueGroup::singleton()->push( $jobs ); // Job to update link tables for a set of titles } elseif ( isset( $this->params['pages'] ) ) { - foreach ( $this->params['pages'] as $pageId => $nsAndKey ) { + foreach ( $this->params['pages'] as $nsAndKey ) { list( $ns, $dbKey ) = $nsAndKey; $this->runForTitle( Title::makeTitleSafe( $ns, $dbKey ) ); } @@ -207,7 +207,7 @@ class RefreshLinksJob extends Job { if ( $page->getTouched() >= $this->params['rootJobTimestamp'] || $opportunistic ) { // Cache is suspected to be up-to-date. As long as the cache rev ID matches // and it reflects the job's triggering change, then it is usable. - $parserOutput = ParserCache::singleton()->getDirty( $page, $parserOptions ); + $parserOutput = $services->getParserCache()->getDirty( $page, $parserOptions ); if ( !$parserOutput || $parserOutput->getCacheRevisionId() != $revision->getId() || $parserOutput->getCacheTime() < $skewedTimestamp @@ -234,7 +234,7 @@ class RefreshLinksJob extends Job { && $parserOutput->isCacheable() ) { $ctime = wfTimestamp( TS_MW, (int)$start ); // cache time - ParserCache::singleton()->save( + $services->getParserCache()->save( $parserOutput, $page, $parserOptions, $ctime, $revision->getId() ); } @@ -253,7 +253,7 @@ class RefreshLinksJob extends Job { // This avoids snapshot-clearing errors in LinksUpdate::acquirePageLock(). $lbFactory->commitAndWaitForReplication( __METHOD__, $ticket ); - foreach ( $updates as $key => $update ) { + foreach ( $updates as $update ) { // FIXME: This code probably shouldn't be here? // Needed by things like Echo notifications which need // to know which user caused the links update @@ -279,6 +279,10 @@ class RefreshLinksJob extends Job { InfoAction::invalidateCache( $title ); + // Commit any writes here in case this method is called in a loop. + // In that case, the scoped lock will fail to be acquired. + $lbFactory->commitAndWaitForReplication( __METHOD__, $ticket ); + return true; } @@ -287,7 +291,7 @@ class RefreshLinksJob extends Job { if ( is_array( $info['params'] ) ) { // For per-pages jobs, the job title is that of the template that changed // (or similar), so remove that since it ruins duplicate detection - if ( isset( $info['pages'] ) ) { + if ( isset( $info['params']['pages'] ) ) { unset( $info['namespace'] ); unset( $info['title'] ); } @@ -297,6 +301,12 @@ class RefreshLinksJob extends Job { } public function workItemCount() { - return isset( $this->params['pages'] ) ? count( $this->params['pages'] ) : 1; + if ( !empty( $this->params['recursive'] ) ) { + return 0; // nothing actually refreshed + } elseif ( isset( $this->params['pages'] ) ) { + return count( $this->params['pages'] ); + } + + return 1; // one title } }