From 487e9dc599298b57e5583f19945987ce0b0f287b Mon Sep 17 00:00:00 2001 From: Kunal Mehta Date: Tue, 22 Apr 2014 09:56:40 -0700 Subject: [PATCH] API: Don't rollback changes if the exception was a UsageException In I1b7396ceb, we were trying to log failures to Special:Log, but since $this->dieUsage throws an exception, the log entry insertion was being rolled back. This is similar to I36cd645d which was for index.php calls. Change-Id: I136ba66d2f939fcdd0c9326e04d686a30449bf4c Follows-Up: I8f1da51187b281fe4afc0d5a0c49f5caf3612e92 --- includes/api/ApiMain.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/includes/api/ApiMain.php b/includes/api/ApiMain.php index ab7c0a627c..078e57a294 100644 --- a/includes/api/ApiMain.php +++ b/includes/api/ApiMain.php @@ -387,7 +387,10 @@ class ApiMain extends ApiBase { */ protected function handleException( Exception $e ) { // Bug 63145: Rollback any open database transactions - MWExceptionHandler::rollbackMasterChangesAndLog( $e ); + if ( !( $e instanceof UsageException ) ) { + // UsageExceptions are intentional, so don't rollback if that's the case + MWExceptionHandler::rollbackMasterChangesAndLog( $e ); + } // Allow extra cleanup and logging wfRunHooks( 'ApiMain::onException', array( $this, $e ) ); -- 2.20.1