jenkins-bot has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/367325 )

Change subject: If the repo is a client, it should dispatch changes to itself.
......................................................................


If the repo is a client, it should dispatch changes to itself.

Bug: T113606
Change-Id: I4195e08b2345880f8380f76c329544d603c804d1
---
M repo/maintenance/dispatchChanges.php
1 file changed, 26 insertions(+), 5 deletions(-)

Approvals:
  WMDE-leszek: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/repo/maintenance/dispatchChanges.php 
b/repo/maintenance/dispatchChanges.php
index c507954..3c59481 100644
--- a/repo/maintenance/dispatchChanges.php
+++ b/repo/maintenance/dispatchChanges.php
@@ -8,6 +8,7 @@
 use MediaWiki\MediaWikiServices;
 use MWException;
 use MWExceptionHandler;
+use UnexpectedValueException;
 use Wikibase\Lib\Reporting\ObservableMessageReporter;
 use Wikibase\Lib\Reporting\ReportingExceptionHandler;
 use Wikibase\Lib\Store\Sql\EntityChangeLookup;
@@ -17,6 +18,7 @@
 use Wikibase\Repo\Store\Sql\LockManagerSqlChangeDispatchCoordinator;
 use Wikibase\Store\Sql\SqlChangeDispatchCoordinator;
 use Wikibase\Store\Sql\SqlSubscriptionLookup;
+use Wikimedia\Assert\Assert;
 
 $basePath = getenv( 'MW_INSTALL_PATH' ) !== false ? getenv( 'MW_INSTALL_PATH' 
) : __DIR__ . '/../../../..';
 
@@ -64,18 +66,34 @@
        }
 
        /**
-        * @param SettingsArray $settings
+        * @param string[] $clientWikis as defined in the localClientDatabases 
config setting.
         *
         * @return string[] A mapping of client wiki site IDs to logical 
database names.
         */
-       private function getClientWikis( SettingsArray $settings ) {
-               $clientWikis = $settings->getSetting( 'localClientDatabases' );
+       private function getClientWikis( array $clientWikis ) {
+               Assert::parameterElementType( 'string', $clientWikis, 
'$clientWikis' );
 
                // make sure we have a mapping from siteId to database name in 
clientWikis:
                foreach ( $clientWikis as $siteID => $dbName ) {
                        if ( is_int( $siteID ) ) {
                                unset( $clientWikis[$siteID] );
-                               $clientWikis[$dbName] = $dbName;
+                               $siteID = $dbName;
+                       }
+                       $clientWikis[$siteID] = $dbName;
+               }
+
+               // If this repo is also a client, make sure it dispatches also 
to itself.
+               if ( WikibaseSettings::isClientEnabled() ) {
+                       $clientSettings = WikibaseSettings::getClientSettings();
+                       $repoName = $clientSettings->getSetting( 'repoSiteId' );
+                       $repoDb = $clientSettings->getSetting( 'repoDatabase' );
+
+                       if ( $repoDb === false ) {
+                               $repoDb = 
MediaWikiServices::getInstance()->getMainConfig()->get( 'DBname' );
+                       }
+
+                       if ( !isset( $clientWikis[$repoName] ) ) {
+                               $clientWikis[$repoName] = $repoDb;
                        }
                }
 
@@ -165,7 +183,10 @@
                $delay = (int)$this->getOption( 'idle-delay', 10 );
 
                $wikibaseRepo = WikibaseRepo::getDefaultInstance();
-               $clientWikis = $this->getClientWikis( 
$wikibaseRepo->getSettings() );
+
+               $clientWikis = $this->getClientWikis(
+                       $wikibaseRepo->getSettings()->getSetting( 
'localClientDatabases' )
+               );
 
                if ( empty( $clientWikis ) ) {
                        throw new MWException( "No client wikis configured! 
Please set \$wgWBRepoSettings['localClientDatabases']." );

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I4195e08b2345880f8380f76c329544d603c804d1
Gerrit-PatchSet: 6
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Daniel Kinzler <[email protected]>
Gerrit-Reviewer: Aude <[email protected]>
Gerrit-Reviewer: Daniel Kinzler <[email protected]>
Gerrit-Reviewer: Hoo man <[email protected]>
Gerrit-Reviewer: Ladsgroup <[email protected]>
Gerrit-Reviewer: Thiemo Mättig (WMDE) <[email protected]>
Gerrit-Reviewer: WMDE-leszek <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to