From: Marius Hoch Date: Tue, 16 Jul 2019 11:15:57 +0000 (+0200) Subject: doMaintenance: Try to print errors to stderr X-Git-Tag: 1.34.0-rc.0~968^2 X-Git-Url: http://git.cyclocoop.org/%22%20.%20generer_url_aide%28?a=commitdiff_plain;h=3f7fa975e03add4f6d57a98e54fcef8c49712676;p=lhc%2Fweb%2Fwiklou.git doMaintenance: Try to print errors to stderr Don't mix them in with stdout (which might be redirected, like dump output, making the errors hard to discover). Change-Id: Ibed8c0e8dde3e44de60bf32abd3fc5ce5d29e1ba --- diff --git a/maintenance/doMaintenance.php b/maintenance/doMaintenance.php index 0ee1e6a0b8..fe4905b228 100644 --- a/maintenance/doMaintenance.php +++ b/maintenance/doMaintenance.php @@ -99,12 +99,20 @@ try { $success = $maintenance->execute(); } catch ( Exception $ex ) { $success = false; + $exReportMessage = ''; while ( $ex ) { $cls = get_class( $ex ); - print "$cls from line {$ex->getLine()} of {$ex->getFile()}: {$ex->getMessage()}\n"; - print $ex->getTraceAsString() . "\n"; + $exReportMessage .= "$cls from line {$ex->getLine()} of {$ex->getFile()}: {$ex->getMessage()}\n"; + $exReportMessage .= $ex->getTraceAsString() . "\n"; $ex = $ex->getPrevious(); } + // Print the exception to stderr if possible, don't mix it in + // with stdout output. + if ( defined( 'STDERR' ) ) { + fwrite( STDERR, $exReportMessage ); + } else { + echo $exReportMessage; + } } // Potentially debug globals