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" );
}
}
+ /**
+ * 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.
* Print a message, if possible to STDERR.
* Use this in command line mode only (see isCommandLine)
*
+ * @suppress SecurityCheck-XSS
* @param string $message Failure text
*/
private static function printError( $message ) {