From 831a14ab85dd961778469d0feef27af2751ed691 Mon Sep 17 00:00:00 2001 From: Chad Horohoe Date: Wed, 22 Jun 2011 21:48:46 +0000 Subject: [PATCH] Make Maintenance::error() more useful in dying situations by turning the second parameter into an int to allow dying errors to specify an exit code. Bool t/f will still work for b/c --- maintenance/Maintenance.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/maintenance/Maintenance.php b/maintenance/Maintenance.php index aac62e0f7f..b48820850f 100644 --- a/maintenance/Maintenance.php +++ b/maintenance/Maintenance.php @@ -314,9 +314,9 @@ abstract class Maintenance { * Throw an error to the user. Doesn't respect --quiet, so don't use * this for non-error output * @param $err String: the error to display - * @param $die Boolean: If true, go ahead and die out. + * @param $die Int: if > 0, go ahead and die out using this int as the code */ - protected function error( $err, $die = false ) { + protected function error( $err, $die = 0 ) { $this->outputChanneled( false ); if ( php_sapi_name() == 'cli' ) { fwrite( STDERR, $err . "\n" ); @@ -325,8 +325,9 @@ abstract class Maintenance { fwrite( $f, $err . "\n" ); fclose( $f ); } - if ( $die ) { - die(); + $die = intval( $die ); + if ( $die > 0 ) { + die( $die ); } } -- 2.20.1