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

Remove all deprecations from Action Pack #26746

Merged
merged 23 commits into from Oct 10, 2016
Commits
Jump to file or symbol
Failed to load files and symbols.
+5 −27
Diff settings

Always

Just for now

Viewing a subset of changes. View all

Remove deprecated methods in ActionController::Parameters

  • Loading branch information...
rafaelfranca committed May 23, 2016
commit 7093ceb480ad6a0a91b511832dad4c6a86981b93
View
@@ -1,3 +1,7 @@
* Remove deprecated methods in `ActionController::Parameters`.
*Rafael Mendonça França*
* Remove deprecated support to comparing a `ActionController::Parameters`
with a `Hash`.
@@ -611,28 +611,8 @@ def init_with(coder) # :nodoc:
end
end
# Undefine `to_param` such that it gets caught in the `method_missing`
# deprecation cycle below.
undef_method :to_param

This comment has been minimized.

@kaspth

kaspth Oct 10, 2016

Member

Should we still undef this?

@kaspth

kaspth Oct 10, 2016

Member

Should we still undef this?

This comment has been minimized.

@rafaelfranca

rafaelfranca Oct 10, 2016

Member

I think so. The idea to undef this was to users not call to_param on parameters expecting the hash behavior and getting the to_s result. If we keep it defined it will silently break again and users will have the wrong behavior.

@rafaelfranca

rafaelfranca Oct 10, 2016

Member

I think so. The idea to undef this was to users not call to_param on parameters expecting the hash behavior and getting the to_s result. If we keep it defined it will silently break again and users will have the wrong behavior.

This comment has been minimized.

@kaspth

kaspth Oct 10, 2016

Member

👌

@kaspth

kaspth Oct 10, 2016

Member

👌

def method_missing(method_sym, *args, &block)
if @parameters.respond_to?(method_sym)
message = <<-DEPRECATE.squish
Method #{method_sym} is deprecated and will be removed in Rails 5.1,
as `ActionController::Parameters` no longer inherits from
hash. Using this deprecated behavior exposes potential security
problems. If you continue to use this method you may be creating
a security vulnerability in your app that can be exploited. Instead,
consider using one of these documented methods which are not
deprecated: http://api.rubyonrails.org/v#{ActionPack.version}/classes/ActionController/Parameters.html
DEPRECATE
ActiveSupport::Deprecation.warn(message)
@parameters.public_send(method_sym, *args, &block)
else
super
end
end
protected
attr_reader :parameters
@@ -72,14 +72,8 @@ class ParametersRequireTest < ActiveSupport::TestCase
assert params.value?("cinco")
end
test "Deprecated methods are deprecated" do
assert_deprecated do
ActionController::Parameters.new(foo: "bar").merge!(bar: "foo")
end
end
test "to_query is not supported" do
assert_deprecated do
assert_raises(NoMethodError) do
ActionController::Parameters.new(foo: "bar").to_param
end
end
ProTip! Use n and p to navigate between commits in a pull request.