Daniel Kinzler has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/367325 )

Change subject: Use proper DB name for local wiki in wb_changes_dispatch table.
......................................................................

Use proper DB name for local wiki in wb_changes_dispatch table.

The database name was previously recorded as "0" for the local database
if the list of client databases represented the local db name as `false`,
as is common in MediaWiki.

Note that this change should not have any effect on the live site:

Firstly, the changed code will only affect what value will be used
when inserting new rows into changedispatch. This only happens when
new wikis are added to the client list. For wikidata.org, the local
(repo) wiki is already present in the table.

Secondly, this is only relevant if the local wiki is represented as
`false` in the list of clients. This is not the case for the live
site.

Thirdly, the value of the chd_db field is only used for logging and
reporting. It has no impact on behavior.

Change-Id: I4195e08b2345880f8380f76c329544d603c804d1
---
M repo/maintenance/dispatchChanges.php
1 file changed, 16 insertions(+), 7 deletions(-)


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

diff --git a/repo/maintenance/dispatchChanges.php 
b/repo/maintenance/dispatchChanges.php
index c507954..92ba701 100644
--- a/repo/maintenance/dispatchChanges.php
+++ b/repo/maintenance/dispatchChanges.php
@@ -64,19 +64,23 @@
        }
 
        /**
-        * @param SettingsArray $settings
+        * @param array $clientWikis
+        * @param string $localDBname
         *
         * @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, $localDBname ) {
                // make sure we have a mapping from siteId to database name in 
clientWikis:
                foreach ( $clientWikis as $siteID => $dbName ) {
+                       if ( $dbName === false ) {
+                               // resolve local DB name
+                               $dbName = $localDBname;
+                       }
                        if ( is_int( $siteID ) ) {
                                unset( $clientWikis[$siteID] );
-                               $clientWikis[$dbName] = $dbName;
+                               $siteID = $dbName;
                        }
+                       $clientWikis[$siteID] = $dbName;
                }
 
                return $clientWikis;
@@ -165,7 +169,12 @@
                $delay = (int)$this->getOption( 'idle-delay', 10 );
 
                $wikibaseRepo = WikibaseRepo::getDefaultInstance();
-               $clientWikis = $this->getClientWikis( 
$wikibaseRepo->getSettings() );
+               $mediaWikiServices = MediaWikiServices::getInstance();
+
+               $clientWikis = $this->getClientWikis(
+                       $wikibaseRepo->getSettings()->getSetting( 
'localClientDatabases' ),
+                       $mediaWikiServices->getMainConfig()->get( 'DBname' )
+               );
 
                if ( empty( $clientWikis ) ) {
                        throw new MWException( "No client wikis configured! 
Please set \$wgWBRepoSettings['localClientDatabases']." );
@@ -179,7 +188,7 @@
 
                $dispatcher->getDispatchCoordinator()->initState( $clientWikis 
);
 
-               $stats = 
MediaWikiServices::getInstance()->getStatsdDataFactory();
+               $stats = $mediaWikiServices->getStatsdDataFactory();
                $stats->increment( 'wikibase.repo.dispatchChanges.start' );
 
                $passes = $maxPasses === PHP_INT_MAX ? "unlimited" : $maxPasses;

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I4195e08b2345880f8380f76c329544d603c804d1
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Daniel Kinzler <daniel.kinz...@wikimedia.de>

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

Reply via email to