Krinkle has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/371643 )

Change subject: Disallow job pushes from JobQueueGroup to bogus wikis
......................................................................

Disallow job pushes from JobQueueGroup to bogus wikis

Bug: T171371
Change-Id: I03a5dbd18cf6b5bcacb3ec07cef9e0b051bc147c
(cherry picked from commit df7ec19a120ddcc9e2147808a2f0768a641e89ba)
---
M includes/jobqueue/JobQueueGroup.php
1 file changed, 22 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/43/371643/1

diff --git a/includes/jobqueue/JobQueueGroup.php 
b/includes/jobqueue/JobQueueGroup.php
index ef0ecb3..addc7fc 100644
--- a/includes/jobqueue/JobQueueGroup.php
+++ b/includes/jobqueue/JobQueueGroup.php
@@ -37,6 +37,8 @@
        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;
@@ -68,9 +70,17 @@
         * @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];
@@ -120,6 +130,13 @@
         */
        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 ) ) {
@@ -171,6 +188,11 @@
         * @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;

-- 
To view, visit https://gerrit.wikimedia.org/r/371643
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I03a5dbd18cf6b5bcacb3ec07cef9e0b051bc147c
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: wmf/1.30.0-wmf.13
Gerrit-Owner: Krinkle <krinklem...@gmail.com>
Gerrit-Reviewer: Aaron Schulz <asch...@wikimedia.org>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to