(bug 42949) API shouldn't assume all exceptions are MWException

Since I20525253, the exception-handling code in ApiMain has
inadvertently assumed that all thrown exceptions will be subclasses of
MWException. This change restores the check for MWException while
preserving the new check for not UsageException introduced in that
commit.

Change-Id: I5016143a07c871bae910e93b22fefe61a959780c
This commit is contained in:
Brad Jorsch 2012-12-11 09:12:08 -05:00 committed by Alexandre Emsenhuber
parent 1ea3840983
commit a97f3550a0
2 changed files with 2 additions and 1 deletions

View file

@ -123,6 +123,7 @@ production.
log when determining whether an account is used. log when determining whether an account is used.
* (bug 43379) Gracefully fail if rev_len is unavailable for a revision on the * (bug 43379) Gracefully fail if rev_len is unavailable for a revision on the
History page. History page.
* (bug 42949) API no longer assumes all exceptions are MWException.
=== API changes in 1.21 === === API changes in 1.21 ===
* prop=revisions can now report the contentmodel and contentformat. * prop=revisions can now report the contentmodel and contentformat.

View file

@ -375,7 +375,7 @@ class ApiMain extends ApiBase {
wfRunHooks( 'ApiMain::onException', array( $this, $e ) ); wfRunHooks( 'ApiMain::onException', array( $this, $e ) );
// Log it // Log it
if ( !( $e instanceof UsageException ) ) { if ( $e instanceof MWException && !( $e instanceof UsageException ) ) {
global $wgLogExceptionBacktrace; global $wgLogExceptionBacktrace;
if ( $wgLogExceptionBacktrace ) { if ( $wgLogExceptionBacktrace ) {
wfDebugLog( 'exception', $e->getLogMessage() . "\n" . $e->getTraceAsString() . "\n" ); wfDebugLog( 'exception', $e->getLogMessage() . "\n" . $e->getTraceAsString() . "\n" );