X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=blobdiff_plain;f=includes%2Fjobqueue%2FJobQueueGroup.php;h=addc7fc2e112f624ee4786cb88390ab7adcd5fbf;hp=5d5ea26df616a22472645a2dceafcd0d6c6a6a75;hb=89539f2aa1b158fdcc703ad053e2580cb97a6385;hpb=3cecf7e6f1b6b30e86c3b08372ecf200bd5a9018 diff --git a/includes/jobqueue/JobQueueGroup.php b/includes/jobqueue/JobQueueGroup.php index 5d5ea26df6..addc7fc2e1 100644 --- a/includes/jobqueue/JobQueueGroup.php +++ b/includes/jobqueue/JobQueueGroup.php @@ -18,7 +18,6 @@ * http://www.gnu.org/copyleft/gpl.html * * @file - * @author Aaron Schulz */ /** @@ -38,6 +37,8 @@ class JobQueueGroup { protected $wiki; /** @var string|bool Read only rationale (or false if r/w) */ protected $readOnlyReason; + /** @var bool Whether the wiki is not recognized in configuration */ + protected $invalidWiki = false; /** @var array Map of (bucket => (queue => JobQueue, types => list of types) */ protected $coalescedQueues; @@ -69,9 +70,17 @@ class JobQueueGroup { * @return JobQueueGroup */ public static function singleton( $wiki = false ) { + global $wgLocalDatabases; + $wiki = ( $wiki === false ) ? wfWikiID() : $wiki; + if ( !isset( self::$instances[$wiki] ) ) { self::$instances[$wiki] = new self( $wiki, wfConfiguredReadOnlyReason() ); + // Make sure jobs are not getting pushed to bogus wikis. This can confuse + // the job runner system into spawning endless RPC requests that fail (T171371). + if ( $wiki !== wfWikiID() && !in_array( $wiki, $wgLocalDatabases ) ) { + self::$instances[$wiki]->invalidWiki = true; + } } return self::$instances[$wiki]; @@ -122,6 +131,13 @@ class JobQueueGroup { public function push( $jobs ) { global $wgJobTypesExcludedFromDefaultQueue; + if ( $this->invalidWiki ) { + // Do not enqueue job that cannot be run (T171371) + $e = new LogicException( "Domain '{$this->wiki}' is not recognized." ); + MWExceptionHandler::logException( $e ); + return; + } + $jobs = is_array( $jobs ) ? $jobs : [ $jobs ]; if ( !count( $jobs ) ) { return; @@ -172,6 +188,11 @@ class JobQueueGroup { * @since 1.26 */ public function lazyPush( $jobs ) { + if ( $this->invalidWiki ) { + // Do not enqueue job that cannot be run (T171371) + throw new LogicException( "Domain '{$this->wiki}' is not recognized." ); + } + if ( PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg' ) { $this->push( $jobs ); return;