r90611 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r90610‎ | r90611 | r90612 >
Date:21:48, 22 June 2011
Author:demon
Status:ok
Tags:
Comment:
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
Modified paths:
  • /trunk/phase3/maintenance/Maintenance.php (modified) (history)

Diff [purge]

Index: trunk/phase3/maintenance/Maintenance.php
@@ -314,9 +314,9 @@
315315 * Throw an error to the user. Doesn't respect --quiet, so don't use
316316 * this for non-error output
317317 * @param $err String: the error to display
318 - * @param $die Boolean: If true, go ahead and die out.
 318+ * @param $die Int: if > 0, go ahead and die out using this int as the code
319319 */
320 - protected function error( $err, $die = false ) {
 320+ protected function error( $err, $die = 0 ) {
321321 $this->outputChanneled( false );
322322 if ( php_sapi_name() == 'cli' ) {
323323 fwrite( STDERR, $err . "\n" );
@@ -325,8 +325,9 @@
326326 fwrite( $f, $err . "\n" );
327327 fclose( $f );
328328 }
329 - if ( $die ) {
330 - die();
 329+ $die = intval( $die );
 330+ if ( $die > 0 ) {
 331+ die( $die );
331332 }
332333 }
333334

Status & tagging log