X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fapi%2FApiMain.php;h=2e16312eaaa7811f602a1dda55e6dd62e4d55ef2;hb=a8304d4c73fd04c338ae23f3028fc475921cc0fa;hp=8f270dcb18acbe27511f46cd146fcf15b8e7fae7;hpb=bedc38649bae342c30b0ac86ad2fa71f663528da;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/api/ApiMain.php b/includes/api/ApiMain.php index 8f270dcb18..2e16312eaa 100644 --- a/includes/api/ApiMain.php +++ b/includes/api/ApiMain.php @@ -68,7 +68,6 @@ class ApiMain extends ApiBase { 'purge' => 'ApiPurge', 'setnotificationtimestamp' => 'ApiSetNotificationTimestamp', 'rollback' => 'ApiRollback', - 'runjobs' => 'ApiRunJobs', 'delete' => 'ApiDelete', 'undelete' => 'ApiUndelete', 'protect' => 'ApiProtect', @@ -387,6 +386,9 @@ class ApiMain extends ApiBase { * @param Exception $e */ protected function handleException( Exception $e ) { + // Bug 63145: Rollback any open database transactions + MWExceptionHandler::rollbackMasterChangesAndLog( $e ); + // Allow extra cleanup and logging wfRunHooks( 'ApiMain::onException', array( $this, $e ) ); @@ -642,6 +644,7 @@ class ApiMain extends ApiBase { global $wgShowHostnames; $result = $this->getResult(); + // Printer may not be initialized if the extractRequestParams() fails for the main module if ( !isset( $this->mPrinter ) ) { // The printer has not been created yet. Try to manually get formatter value. @@ -651,11 +654,18 @@ class ApiMain extends ApiBase { } $this->mPrinter = $this->createPrinterByName( $value ); - if ( $this->mPrinter->getNeedsRawData() ) { - $result->setRawMode(); - } } + // Printer may not be able to handle errors. This is particularly + // likely if the module returns something for getCustomPrinter(). + if ( !$this->mPrinter->canPrintErrors() ) { + $this->mPrinter->safeProfileOut(); + $this->mPrinter = $this->createPrinterByName( self::API_DEFAULT_FORMAT ); + } + + // Update raw mode flag for the selected printer. + $result->setRawMode( $this->mPrinter->getNeedsRawData() ); + if ( $e instanceof UsageException ) { // User entered incorrect parameters - print usage screen $errMessage = $e->getMessageArray();