From 2f29380c18d7754cefffbc09bebaa2007fb99929 Mon Sep 17 00:00:00 2001 From: Eugene Kenny Date: Thu, 10 May 2018 00:24:04 +0100 Subject: Don't clear transaction state after manual rollback If an `ActiveRecord::Rollback` error was raised by a persistence method (e.g. in an `after_save` callback), this logic would potentially discard the original state of the record from before the transaction, preventing it from being restored later when the transaction was rolled back. --- activerecord/lib/active_record/transactions.rb | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) (limited to 'activerecord/lib/active_record') diff --git a/activerecord/lib/active_record/transactions.rb b/activerecord/lib/active_record/transactions.rb index be4f41050e..6e9dff5796 100644 --- a/activerecord/lib/active_record/transactions.rb +++ b/activerecord/lib/active_record/transactions.rb @@ -382,13 +382,7 @@ module ActiveRecord status = nil self.class.transaction do add_to_transaction - begin - status = yield - rescue ActiveRecord::Rollback - clear_transaction_record_state - status = nil - end - + status = yield raise ActiveRecord::Rollback unless status end status -- cgit v1.2.3