Remove deprecated passing string to define callback #27608

Merged
merged 2 commits into from Feb 7, 2017

Projects

None yet

3 participants

@kamipo
Member
kamipo commented Jan 8, 2017

And raise ArgumentError when passing string to define callback.

@kamipo kamipo added the activesupport label Jan 8, 2017
- Passing string to define callback is deprecated and will be removed
- in Rails 5.1 without replacement.
+ raise ArgumentError, <<-MSG.squish
+ Passing string to define callback is not supported. Use proc instead.
MSG
end
@kaspth
kaspth Jan 8, 2017 Member

I'm not sure we should add this defensive coding. Presumably people have seen the deprecation warnings and acted on them.

@kamipo
kamipo Jan 8, 2017 Member

We still have string eval code for if and unless conditional options. Therefore passing string to define callback works again unless raising an error.

https://github.com/rails/rails/blob/v5.0.1/activesupport/test/callbacks_test.rb#L197-L201

@kaspth
kaspth Jan 15, 2017 Member

@rafaelfranca @matthewd is the original deprecation warning obtuse enough that we could construe it to mean …also don't use strings in :if and :unless?

@rafaelfranca
rafaelfranca Jan 18, 2017 Member

In that case we will have to deprecate it now since we didn't before. @kamipo could you also deprecate it in a new commit in this PR?

@kamipo
kamipo Jan 18, 2017 Member

Sure, will do.

@kaspth
Member
kaspth commented Jan 8, 2017

@rafaelfranca since you removed most of the deprecations. r? @rafaelfranca

@rafaelfranca
Member

I should not merge this PR since deprecations removal should only be done by the release manager, but since this was not an easy one I'll merge it. But please don't open new PRs removing deprecation, better to open issues pointing ones that we forgot. I was aware of this one and was going to remove it with the return false callback deprecation.

@kamipo
Member
kamipo commented Jan 18, 2017

Okay. BTW we still have another deprecation for deprecated_false_terminator. Do we remove the deprecation for Rails 5.1?

https://github.com/rails/rails/blob/ac387e8e6d242204731ed9eff333ac491f15c55d/activesupport/lib/active_support/callbacks.rb#L862-L867

          def display_deprecation_warning_for_false_terminator
            ActiveSupport::Deprecation.warn(<<-MSG.squish)
              Returning `false` in Active Record and Active Model callbacks will not implicitly halt a callback chain in Rails 5.1.
              To explicitly halt the callback chain, please use `throw :abort` instead.
            MSG
          end
@rafaelfranca
Member
@kamipo
Member
kamipo commented Jan 19, 2017

I added the deprecation for :if and :unless options.

kamipo added some commits Jan 8, 2017
@kamipo kamipo Remove deprecated passing string to define callback
And raise `ArgumentError` when passing string to define callback.
f8d3fed
@kamipo kamipo Deprecate passing string to `:if` and `:unless` conditional options o…
…n `set_callback` and `skip_callback`
0952552
@rafaelfranca rafaelfranca merged commit d7bbe07 into rails:master Feb 7, 2017

1 check passed

codeclimate no new or fixed issues
Details
@kamipo kamipo deleted the kamipo:remove_deprecated_passing_string_to_define_callback branch Feb 7, 2017
@y-yagi y-yagi added a commit to y-yagi/rails that referenced this pull request Feb 18, 2017
@y-yagi y-yagi Remove deprecate passing string to `:if` and `:unless` conditional op…
…tions [ci skip]

Follow up to #27608
53ff5fc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment