aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/transactions.rb
diff options
context:
space:
mode:
authorBrian Durand <bbdurand@gmail.com>2018-05-03 17:27:20 -0700
committerBrian Durand <bbdurand@gmail.com>2018-05-04 10:21:17 -0700
commita779b1a08bb73be2b50d42ae69b3946de98e5af4 (patch)
tree79ef12cdb86f5730ad2c0d0171bdaf6b609b35ce /activerecord/lib/active_record/transactions.rb
parent98c1432583d4607af1467425183d8d448a692c5a (diff)
downloadrails-a779b1a08bb73be2b50d42ae69b3946de98e5af4.tar.gz
rails-a779b1a08bb73be2b50d42ae69b3946de98e5af4.tar.bz2
rails-a779b1a08bb73be2b50d42ae69b3946de98e5af4.zip
Fix logic on disabling commit callbacks
Commit callbacks are intentionally disabled when errors occur when calling the callback chain in order to reset the internal record state. However, the implicit order of operations on the logic for checking if callbacks are disabled is wrong. The result is that callbacks can be unexpectedly when errors occur in transactions.
Diffstat (limited to 'activerecord/lib/active_record/transactions.rb')
-rw-r--r--activerecord/lib/active_record/transactions.rb2
1 files changed, 1 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/transactions.rb b/activerecord/lib/active_record/transactions.rb
index 97cba5d1c7..be4f41050e 100644
--- a/activerecord/lib/active_record/transactions.rb
+++ b/activerecord/lib/active_record/transactions.rb
@@ -340,7 +340,7 @@ module ActiveRecord
# Ensure that it is not called if the object was never persisted (failed create),
# but call it after the commit of a destroyed object.
def committed!(should_run_callbacks: true) #:nodoc:
- if should_run_callbacks && destroyed? || persisted?
+ if should_run_callbacks && (destroyed? || persisted?)
_run_commit_without_transaction_enrollment_callbacks
_run_commit_callbacks
end