Merge "Print chained exceptions when maintenance script fails."
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Wed, 29 May 2019 20:21:01 +0000 (20:21 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Wed, 29 May 2019 20:21:01 +0000 (20:21 +0000)
1  2 
maintenance/doMaintenance.php

@@@ -61,7 -61,6 +61,7 @@@ if ( !defined( 'MW_CONFIG_CALLBACK' ) &
  
  // Custom setup for Maintenance entry point
  if ( !defined( 'MW_SETUP_CALLBACK' ) ) {
 +
        function wfMaintenanceSetup() {
                // phpcs:ignore MediaWiki.NamingConventions.ValidGlobalName.wgPrefix
                global $maintenance, $wgLocalisationCacheConf, $wgCacheDirectory;
@@@ -76,7 -75,6 +76,7 @@@
  
                $maintenance->finalSetup();
        }
 +
        define( 'MW_SETUP_CALLBACK', 'wfMaintenanceSetup' );
  }
  
@@@ -92,10 -90,18 +92,20 @@@ $maintenance->checkRequiredExtensions()
  // This avoids having long running scripts just OOM and lose all the updates.
  $maintenance->setAgentAndTriggers();
  
 +$maintenance->validateParamsAndArgs();
 +
  // Do the work
- $success = $maintenance->execute();
+ try {
+       $success = $maintenance->execute();
+ } catch ( Exception $ex ) {
+       $success = false;
+       while ( $ex ) {
+               $cls = get_class( $ex );
+               print "$cls from line {$ex->getLine()} of {$ex->getFile()}: {$ex->getMessage()}\n";
+               print $ex->getTraceAsString() . "\n";
+               $ex = $ex->getPrevious();
+       }
+ }
  
  // Potentially debug globals
  $maintenance->globals();