Merge "exception: No longer try to send error page post-send on api.php"

This commit is contained in:
jenkins-bot 2020-03-26 18:23:22 +00:00 committed by Gerrit Code Review
commit 93f8e2e1f7
2 changed files with 12 additions and 8 deletions

View file

@ -33,7 +33,9 @@ class MWException extends Exception {
return $this->useMessageCache() &&
!empty( $GLOBALS['wgFullyInitialised'] ) &&
!empty( $GLOBALS['wgOut'] ) &&
!defined( 'MEDIAWIKI_INSTALL' );
!defined( 'MEDIAWIKI_INSTALL' ) &&
// Don't send a skinned HTTP 500 page to API clients.
!defined( 'MW_API' );
}
/**
@ -200,10 +202,10 @@ class MWException extends Exception {
global $wgMimeType;
if ( defined( 'MW_API' ) ) {
// Unhandled API exception, we can't be sure that format printer is alive
self::header( 'MediaWiki-API-Error: internal_api_error_' . static::class );
wfHttpError( 500, 'Internal Server Error', $this->getText() );
} elseif ( self::isCommandLine() ) {
}
if ( self::isCommandLine() ) {
$message = $this->getText();
$this->writeToCommandLine( $message );
} else {

View file

@ -50,10 +50,10 @@ class MWExceptionRenderer {
}
if ( defined( 'MW_API' ) ) {
// Unhandled API exception, we can't be sure that format printer is alive
self::header( 'MediaWiki-API-Error: internal_api_error_' . get_class( $e ) );
wfHttpError( 500, 'Internal Server Error', self::getText( $e ) );
} elseif ( self::isCommandLine() ) {
}
if ( self::isCommandLine() ) {
self::printError( self::getText( $e ) );
} elseif ( $mode === self::AS_PRETTY ) {
self::statusHeader( 500 );
@ -119,7 +119,9 @@ class MWExceptionRenderer {
!empty( $GLOBALS['wgFullyInitialised'] ) &&
!empty( $GLOBALS['wgOut'] ) &&
RequestContext::getMain()->getTitle() &&
!defined( 'MEDIAWIKI_INSTALL' )
!defined( 'MEDIAWIKI_INSTALL' ) &&
// Don't send a skinned HTTP 500 page to API clients.
!defined( 'MW_API' )
);
}