X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fexception%2FMWException.php;h=502cee82b7e938bb16bde4e8f87c1debe5228a02;hb=58d70885d875a3928d96a2ca0a74dbc0ec5bb8bb;hp=7f70c4fbaf3ea2111a28431b90e3360ba7cef0f5;hpb=2a6469dbd1aaa7656bb7b18031da38d952af268f;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/exception/MWException.php b/includes/exception/MWException.php index 7f70c4fbaf..502cee82b7 100644 --- a/includes/exception/MWException.php +++ b/includes/exception/MWException.php @@ -209,12 +209,7 @@ class MWException extends Exception { wfHttpError( 500, 'Internal Server Error', $this->getText() ); } elseif ( self::isCommandLine() ) { $message = $this->getText(); - // T17602: STDERR may not be available - if ( !defined( 'MW_PHPUNIT_TEST' ) && defined( 'STDERR' ) ) { - fwrite( STDERR, $message ); - } else { - echo $message; - } + $this->writeToCommandLine( $message ); } else { self::statusHeader( 500 ); self::header( "Content-Type: $wgMimeType; charset=utf-8" ); @@ -223,6 +218,21 @@ class MWException extends Exception { } } + /** + * Write a message to stderr falling back to stdout if stderr unavailable + * + * @param string $message + * @suppress SecurityCheck-XSS + */ + private function writeToCommandLine( $message ) { + // T17602: STDERR may not be available + if ( !defined( 'MW_PHPUNIT_TEST' ) && defined( 'STDERR' ) ) { + fwrite( STDERR, $message ); + } else { + echo $message; + } + } + /** * Check whether we are in command line mode or not to report the exception * in the correct format.