Lucas Werkmeister (WMDE) has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/385338 )

Change subject: Add option to dispatch only to selected clients
......................................................................

Add option to dispatch only to selected clients

Bug: T178666
Change-Id: I4c99f37c74f6b8af3f4d801e61944bfcb1860142
---
M repo/maintenance/dispatchChanges.php
1 file changed, 23 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase 
refs/changes/38/385338/1

diff --git a/repo/maintenance/dispatchChanges.php 
b/repo/maintenance/dispatchChanges.php
index 9c994e4..6c4e95d 100644
--- a/repo/maintenance/dispatchChanges.php
+++ b/repo/maintenance/dispatchChanges.php
@@ -63,6 +63,9 @@
                        . 'selecting pending changes. Default: 15', false, true 
);
                $this->addOption( 'batch-size', 'Maximum number of changes to 
pass to a client at a time. '
                        . 'Default: 1000', false, true );
+               $this->addOption( 'client', 'Only dispatch to the client with 
this site IDs. '
+                       . 'May be specified multiple times to select several 
clients.',
+                       false, true, false, true );
        }
 
        /**
@@ -181,6 +184,7 @@
                $maxTime = (int)$this->getOption( 'max-time', PHP_INT_MAX );
                $maxPasses = (int)$this->getOption( 'max-passes', $maxTime < 
PHP_INT_MAX ? PHP_INT_MAX : 1 );
                $delay = (int)$this->getOption( 'idle-delay', 10 );
+               $selectedClients = $this->getOption( 'client' );
 
                $wikibaseRepo = WikibaseRepo::getDefaultInstance();
 
@@ -192,6 +196,25 @@
                        throw new MWException( "No client wikis configured! 
Please set \$wgWBRepoSettings['localClientDatabases']." );
                }
 
+               if ( $selectedClients !== null ) {
+                       $allClientWikis = $clientWikis;
+                       $clientWikis = [];
+                       foreach ( $selectedClients as $siteID ) {
+                               if ( array_key_exists( $siteID, $allClientWikis 
) ) {
+                                       $clientWikis[$siteID] = 
$allClientWikis[$siteID];
+                               } else {
+                                       throw new MWException(
+                                               "No client wiki with site ID 
$siteID configured! " .
+                                               "Please check 
\$wgWBRepoSettings['localClientDatabases']."
+                                       );
+                               }
+                       }
+
+                       if ( empty( $clientWikis ) ) {
+                               throw new MWException( 'No client wikis 
selected!' );
+                       }
+               }
+
                $dispatcher = $this->newChangeDispatcher(
                        $clientWikis,
                        $wikibaseRepo->getStore()->getEntityChangeLookup(),

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I4c99f37c74f6b8af3f4d801e61944bfcb1860142
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Lucas Werkmeister (WMDE) <lucas.werkmeis...@wikimedia.de>

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

Reply via email to