Make sure DBLoadBalancerFactory service is not disabled
authorRazeSoldier <razesoldier@outlook.com>
Wed, 25 Sep 2019 14:54:13 +0000 (22:54 +0800)
committerReedy <reedy@wikimedia.org>
Sun, 1 Dec 2019 18:00:36 +0000 (18:00 +0000)
After b873e929, when the CLI installation failed, the script will throw
a ServiceDisabledException.
This is because the installer disables DBLoadBalancerFactory service
during instantiation and throws the exception because the installation
failed to restore the service.
So I check if the service is enabled before try commit
the master changes.

Bug: T229601
Change-Id: Ia7589d14ee55bcb03a64856b6dd2c81d8bda783c
(cherry picked from commit eadde762b03ed94c687788ed3e0d9c65e5046fb2)

maintenance/doMaintenance.php

index fe4905b..863ce3b 100644 (file)
@@ -118,7 +118,10 @@ try {
 // Potentially debug globals
 $maintenance->globals();
 
-if ( $maintenance->getDbType() !== Maintenance::DB_NONE ) {
+if ( $maintenance->getDbType() !== Maintenance::DB_NONE &&
+       // Service might be disabled, e.g. when running install.php
+       !MediaWikiServices::getInstance()->isServiceDisabled( 'DBLoadBalancerFactory' )
+) {
        // Perform deferred updates.
        $lbFactory = MediaWikiServices::getInstance()->getDBLoadBalancerFactory();
        $lbFactory->commitMasterChanges( $maintClass );