Use DB domain in JobQueueGroup and make WikiMap domain ID methods stricter
[lhc/web/wiklou.git] / includes / jobqueue / JobQueueFederated.php
index 118b0f9..26886b7 100644 (file)
@@ -73,15 +73,11 @@ class JobQueueFederated extends JobQueue {
         */
        protected function __construct( array $params ) {
                parent::__construct( $params );
-               $section = isset( $params['sectionsByWiki'][$this->wiki] )
-                       ? $params['sectionsByWiki'][$this->wiki]
-                       : 'default';
+               $section = $params['sectionsByWiki'][$this->domain] ?? 'default';
                if ( !isset( $params['partitionsBySection'][$section] ) ) {
                        throw new MWException( "No configuration for section '$section'." );
                }
-               $this->maxPartitionsTry = isset( $params['maxPartitionsTry'] )
-                       ? $params['maxPartitionsTry']
-                       : 2;
+               $this->maxPartitionsTry = $params['maxPartitionsTry'] ?? 2;
                // Get the full partition map
                $partitionMap = $params['partitionsBySection'][$section];
                arsort( $partitionMap, SORT_NUMERIC );
@@ -187,7 +183,7 @@ class JobQueueFederated extends JobQueue {
                // phpcs:ignore Generic.CodeAnalysis.ForLoopWithTestFunctionCall
                for ( $i = $this->maxPartitionsTry; $i > 0 && count( $jobsLeft ); --$i ) {
                        try {
-                               $partitionRing->getLiveRing();
+                               $partitionRing->getLiveLocationWeights();
                        } catch ( UnexpectedValueException $e ) {
                                break; // all servers down; nothing to insert to
                        }
@@ -423,7 +419,7 @@ class JobQueueFederated extends JobQueue {
        }
 
        public function getCoalesceLocationInternal() {
-               return "JobQueueFederated:wiki:{$this->wiki}" .
+               return "JobQueueFederated:wiki:{$this->domain}" .
                        sha1( serialize( array_keys( $this->partitionQueues ) ) );
        }