aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/transactions.rb
diff options
context:
space:
mode:
authorEugene Kenny <elkenny@gmail.com>2018-05-13 02:02:37 +0100
committerEugene Kenny <elkenny@gmail.com>2018-05-13 02:02:37 +0100
commit48007d5390db47fc1223f57c8e7ab3ebb7c3a3d7 (patch)
tree4a8560807a0c46336001db207c96e01e27c5974d /activerecord/lib/active_record/transactions.rb
parent6fac9bd599eeb6b9cacdf7841811223402c501bd (diff)
downloadrails-48007d5390db47fc1223f57c8e7ab3ebb7c3a3d7.tar.gz
rails-48007d5390db47fc1223f57c8e7ab3ebb7c3a3d7.tar.bz2
rails-48007d5390db47fc1223f57c8e7ab3ebb7c3a3d7.zip
Remove ActiveRecord::Transactions#rollback_active_record_state!
`rollback_active_record_state!` was removed from `save!` but not `save` in da840d13da865331297d5287391231b1ed39721b. I believe that leaving it in `save` was a mistake, since that commit was intended to move the rollback logic from the `save`/`save!` call to the transaction stack. As of 67d8bb963d5d51fc644d6b1ca20164efb4cee6d7 the record's original state is lazily restored the first time it's accessed after the transaction, instead of when a rollback occurs. This means that the call to `restore_transaction_record_state` here has no effect: the record's transaction level is incremented twice (in rollback_active_record_state! and `with_transaction_returning_status`), isn't decremented again until the the `ensure` block runs, and won't hit zero until the next time `sync_with_transaction_state` is called.
Diffstat (limited to 'activerecord/lib/active_record/transactions.rb')
-rw-r--r--activerecord/lib/active_record/transactions.rb15
1 files changed, 1 insertions, 14 deletions
diff --git a/activerecord/lib/active_record/transactions.rb b/activerecord/lib/active_record/transactions.rb
index be4f41050e..e1e1c0747b 100644
--- a/activerecord/lib/active_record/transactions.rb
+++ b/activerecord/lib/active_record/transactions.rb
@@ -306,9 +306,7 @@ module ActiveRecord
end
def save(*) #:nodoc:
- rollback_active_record_state! do
- with_transaction_returning_status { super }
- end
+ with_transaction_returning_status { super }
end
def save!(*) #:nodoc:
@@ -319,17 +317,6 @@ module ActiveRecord
with_transaction_returning_status { super }
end
- # Reset id and @new_record if the transaction rolls back.
- def rollback_active_record_state!
- remember_transaction_record_state
- yield
- rescue Exception
- restore_transaction_record_state
- raise
- ensure
- clear_transaction_record_state
- end
-
def before_committed! # :nodoc:
_run_before_commit_without_transaction_enrollment_callbacks
_run_before_commit_callbacks