Don't output skinned errors in case of unhandled API exceptions
authorMax Semenik <maxsem@users.mediawiki.org>
Mon, 20 Feb 2012 19:19:52 +0000 (19:19 +0000)
committerMax Semenik <maxsem@users.mediawiki.org>
Mon, 20 Feb 2012 19:19:52 +0000 (19:19 +0000)
includes/Exception.php

index 3bd89b6..e7700b5 100644 (file)
@@ -203,7 +203,11 @@ class MWException extends Exception {
                        wfDebugLog( 'exception', $log );
                }
 
-               if ( self::isCommandLine() ) {
+               if ( defined( 'MW_API' ) ) {
+                       // Unhandled API exception, we can't be sure that format printer is alive
+                       header( 'MediaWiki-API-Error: internal_api_error_' . get_class( $this ) );
+                       wfHttpError(500, 'Internal Server Error', $this->getText() );
+               } elseif ( self::isCommandLine() ) {
                        MWExceptionHandler::printError( $this->getText() );
                } else {
                        $this->reportHTML();