X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=maintenance%2FMaintenance.php;h=10082e9503d9088af3343849619de4f7c1876a70;hb=d1000765e7ee710bf892e3772afdabfb5f6b1f6c;hp=d37b990b2d5ded41b35ce4aed7dd2c3dbb08a23a;hpb=c9be16a35596ff369bb5f700c20ae8dc2f7def48;p=lhc%2Fweb%2Fwiklou.git diff --git a/maintenance/Maintenance.php b/maintenance/Maintenance.php index d37b990b2d..10082e9503 100644 --- a/maintenance/Maintenance.php +++ b/maintenance/Maintenance.php @@ -398,19 +398,31 @@ abstract class Maintenance { * Throw an error to the user. Doesn't respect --quiet, so don't use * this for non-error output * @param string $err The error to display - * @param int $die If > 0, go ahead and die out using this int as the code + * @param int $die Deprecated since 1.31, use Maintenance::fatalError() instead */ protected function error( $err, $die = 0 ) { + if ( intval( $die ) !== 0 ) { + wfDeprecated( __METHOD__ . '( $err, $die )', '1.31' ); + $this->fatalError( $err, intval( $die ) ); + } $this->outputChanneled( false ); if ( PHP_SAPI == 'cli' ) { fwrite( STDERR, $err . "\n" ); } else { print $err; } - $die = intval( $die ); - if ( $die > 0 ) { - die( $die ); - } + } + + /** + * Output a message and terminate the current script. + * + * @param string $msg Error message + * @param int $exitCode PHP exit status. Should be in range 1-254. + * @since 1.31 + */ + protected function fatalError( $msg, $exitCode = 1 ) { + $this->error( $msg ); + exit( $exitCode ); } private $atLineStart = true; @@ -559,7 +571,7 @@ abstract class Maintenance { $joined = implode( ', ', $missing ); $msg = "The following extensions are required to be installed " . "for this script to run: $joined. Please enable them and then try again."; - $this->error( $msg, 1 ); + $this->fatalError( $msg ); } } @@ -652,17 +664,17 @@ abstract class Maintenance { # Abort if called from a web server if ( isset( $_SERVER ) && isset( $_SERVER['REQUEST_METHOD'] ) ) { - $this->error( 'This script must be run from the command line', true ); + $this->fatalError( 'This script must be run from the command line' ); } if ( $IP === null ) { - $this->error( "\$IP not set, aborting!\n" . - '(Did you forget to call parent::__construct() in your maintenance script?)', 1 ); + $this->fatalError( "\$IP not set, aborting!\n" . + '(Did you forget to call parent::__construct() in your maintenance script?)' ); } # Make sure we can handle script parameters if ( !defined( 'HPHP_VERSION' ) && !ini_get( 'register_argc_argv' ) ) { - $this->error( 'Cannot get command line arguments, register_argc_argv is set to false', true ); + $this->fatalError( 'Cannot get command line arguments, register_argc_argv is set to false' ); } // Send PHP warnings and errors to stderr instead of stdout. @@ -1177,9 +1189,9 @@ abstract class Maintenance { } if ( !is_readable( $settingsFile ) ) { - $this->error( "A copy of your installation's LocalSettings.php\n" . + $this->fatalError( "A copy of your installation's LocalSettings.php\n" . "must exist and be readable in the source directory.\n" . - "Use --conf to specify it.", true ); + "Use --conf to specify it." ); } $wgCommandLineMode = true;