-
Notifications
You must be signed in to change notification settings - Fork 22k
Fix #7127. Don't call after_* callbacks when around_* callbacks returns false. #8479
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
/cc @josevalim |
I was the original reporter of #7127. This PR looks good to me. |
/cc @rafaelfranca |
Hey, is this still an issue on 4.1 @kennyj? Did this ever get a proper review? (/cc @rafaelfranca @carlosantoniodasilva ) |
This would break existing applications which were previously calling methods that return false or nil, which is currently innocuous. Generally around blocks are meant for things like benchmarking, logging, transactions, etc -- and should be causing save to fail. That behavior should be in a before or after callback. If you really need to fail in an around callback, |
This sounds quite reasonable to me: if your 'around' callback fails to yield (i.e., elects to skip the operation it's wrapping), the action didn't occur, so we shouldn't bother with 'after' callbacks. |
Do On Sun, Jun 15, 2014 at 4:54 PM, Matthew Draper notifications@github.com
Thanks, |
@claudiob do you think this is still necessary after your changes? |
@rafaelfranca Let me take a look. For clarity "my changes" means #17227 |
Yes |
@rafaelfranca This issue is not affected by #17227. In fact, I already noticed this behavior when working on that PR and wrote in #17227 (comment):
to which @dhh replied:
|
Right, so lets add this to our TODO list. I'll close this one since it is very likely that the implementation will change. @kennyj thank you for the pull request. |
Please see #7127.
According to https://github.com/rails/rails/blob/master/activesupport/lib/active_support/callbacks.rb#L173-L179 and https://github.com/rails/rails/blob/master/activesupport/lib/active_support/callbacks.rb#L320, if we don't call a block,
value
is not assigned (nil) .Thus I guess we call after_* callbacks incorrectly in the case.