Patch run_callbacks instead#5
Merged
Merged
Conversation
|
🔎 View this PR in Shipit Next. ℹ️ Expand to learn how to deploy and handle emergencies using Shipit NextOverviewShipit Next will merge your code on your behalf because this repository uses Shipit Next and its merge queue. To ship this PR, you can either:
Comment Commands
Commands exclusive to Deploy Before Merge
Documentation
Questions or feedback?
|
493750b to
3b935f3
Compare
Rather than patching the `!` version of the callbacks, we patch the `run_callbacks` method.
This way, we don't need to worry about callbacks potentially being defined _before_ we include the gem,
which can lead to Rails aliasing the non-patched version of the `_run_#{callback}_callbacks!` methods.
Plus, `run_callbacks` is public API, so it's better to patch this anyways.
7f2092d to
a8e8754
Compare
Previously, these methods would've previously reset the transaction_changed_attributes. Now, the no-op version *won't* call `run_callbacks` at all, so we should ensure we still reset the transaction_changed_attributes.
a8e8754 to
8b45764
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Handle changes to Rails' callback code (rails/rails@207a254), which introduces a "fast path" for callbacks and no-ops the
_run_#{callback}_callbacksmethods up until the point where a callback is actually defined, at which point Rails aliases_run_#{callback}_callbacksto a!version of the method.Rather than patching the
!version of the callbacks, we patch therun_callbacksmethod. This way, we don't need to worry about callbacks potentially being defined before we include the gem, which can lead to Rails aliasing the non-patched version of the_run_#{callback}_callbacks!methods.Plus,
run_callbacksis public API, so it's better to patch this anyways.