Skip to content
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 Active Support deprecations #27035

Merged
merged 18 commits into from
Nov 14, 2016
Merged

Conversation

pixeltrix
Copy link
Contributor

This removes the deprecated methods, files and options from Active Support that were explicitly listed for removal from Rails 5.1 with two exceptions:

  1. The qualified constant methods used two singleton methods from ActiveSupport::QualifiedConstUtils - should those be deprecated or just removed straight out since they're not used anywhere else in Rails and it's unlikely they were used in an application.

  2. The string callbacks and returning false are used elsewhere in the Rails test suite so I want to remove them in a separate PR.

Also there are methods with non-specific deprecations like alias_method_chain - is the plan to remove these in 5.1 also?

@rafaelfranca
Copy link
Member

should those be deprecated or just removed straight out since they're not used anywhere else in Rails and it's unlikely they were used in an application.

I'd remove them right now.

Also there are methods with non-specific deprecations like alias_method_chain - is the plan to remove these in 5.1 also?

Yes. If they were deprecated in 5.0 should be removed in 5.1

@pixeltrix pixeltrix merged commit e491b2c into master Nov 14, 2016
@pixeltrix pixeltrix deleted the remove-active-support-deprecations branch November 14, 2016 19:59
@aried3r
Copy link
Contributor

aried3r commented Nov 24, 2016

Since Rails 5.0.0.1 in some cases did not point to the location of the deprecated code but instead pointed to the code where the deprecation warning was printed, what is the recommended path to find these last deprecations? Use the 5-0-stable branch directly (where I think this has been fixed)? I was hoping there would be a 5.0.1 with this fix before 5.1.

Example:

DEPRECATION WARNING: before_filter is deprecated and will be removed in Rails 5.1. Use before_action instead. (called from block (2 levels) in <module:ClassMethods> at /usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/actionpack-5.0.0.1/lib/abstract_controller/callbacks.rb:191)

Source

We only recently made the switch to 5.0 and didn't have time to find all deprecations within our dependencies (our own code doesn't have any).

See also #26686 #24861.

@prathamesh-sonpatki
Copy link
Member

#26686 commit is present in 5-0-stable branch from which 5.0.1 will be released so with 5.0.1 you will be able to see proper locations of the deprecations. Also it will be released before 5.1.

See 363d558

@aried3r
Copy link
Contributor

aried3r commented Nov 24, 2016

Great, thank you! I was unsure (and unable to find any information) about how Rails plans to release everything.

@aried3r
Copy link
Contributor

aried3r commented Dec 7, 2016

so with 5.0.1 you will be able to see proper locations of the deprecations

I recently tried 5.0.1.rc1, and while 38 test cases now fail (I do not yet know why) I also don't see the correct location for all deprecations.

Works (deprecation in Turbolinks Classic):

DEPRECATION WARNING: before_filter is deprecated and will be removed in Rails 5.1. Use before_action instead. (called from block (3 levels) in <class:Engine> at /usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/turbolinks-2.5.3/lib/turbolinks.rb:14)

Doesn't work:

DEPRECATION WARNING: Using positional arguments in functional tests has been deprecated,
in favor of keyword arguments, and will be removed in Rails 5.1.

Deprecated style:
get :show, { id: 1 }, nil, { notice: "This is a flash message" }

New keyword style:
get :show, params: { id: 1 }, flash: { notice: "This is a flash message" },
  session: nil # Can safely be omitted.
 (called from process at /usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/actionpack-5.0.1.rc1/lib/action_controller/test_case.rb:484)

test_case.rb:484. I can't tell which test that is as I ran the whole suite.


*Andrew White*

* Remove deprecated file `active_support/core_ext/time/marshal.rb`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The changelog is confusing here. It is better to say which methods were removed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bogdan not sure what you mean - it was an empty file that was kept around so that it didn't break people's require statements so no methods were removed.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought that there were some methods that were removed and asked to list those... but it looks like it is not the case. Thanks for explaination

thomasjlee added a commit to inventables/nested_has_many_through that referenced this pull request Oct 23, 2021
…ails/rails#27035)

Apparently, defining methods such as :a_with_b and :a_without_b used to be a
common pattern in rails, so alias_method_chain was introduced to encapsulate
this (see: https://apidock.com/rails/ActiveSupport/CoreExtensions/Module/alias_method_chain).

Here is an example of how this works and how we can replace
alias_method_chain with alias_method:

class DeprecatedPerson
  def greet
    "hi"
  end

  def greet_with_excitement
    "#{greet_without_excitement}!!!!!"
  end

  alias_method_chain :greet, :excitement
end

class Person
  def greet
    "hi"
  end

  def greet_with_excitement
    "#{greet_without_excitement}!!!!!"
  end

  alias_method :greet_without_excitement, :greet
  alias_method :greet, :greet_with_excitement
end

tracy = DeprecatedPerson.new
tracy.greet # => "hi!!!!!"
tracy.greet_with_excitement # => "hi!!!!!"
tracy.greet_without_excitement # => "hi"

june = Person.new
june.greet # => "hi!!!!!"
june.greet_with_excitement # => "hi!!!!!"
june.greet_without_excitement # => "hi"

It is necessary to replace alias_method_chain because we use this gem in the
inventables/fbolt repo, and it may take some time to rewrite fbolt such that
this gem is no longer be a dependency.

Meanwhile, we are encountering deprecation warnings which are quite noisy.

Before upgrading from rails 5.0 to 5.1, we will have to address each of the
dependencies that still use alias_method_chain.
thomasjlee added a commit to inventables/nested_has_many_through that referenced this pull request Oct 23, 2021
…ails/rails#27035)

Apparently, defining methods such as :a_with_b and :a_without_b used to be a
common pattern in rails, so alias_method_chain was introduced to encapsulate
this (see: https://apidock.com/rails/ActiveSupport/CoreExtensions/Module/alias_method_chain).

Here is an example of how this works and how we can replace
alias_method_chain with alias_method:

class DeprecatedPerson
  def greet
    "hi"
  end

  def greet_with_excitement
    "#{greet_without_excitement}!!!!!"
  end

  alias_method_chain :greet, :excitement
end

class Person
  def greet
    "hi"
  end

  def greet_with_excitement
    "#{greet_without_excitement}!!!!!"
  end

  alias_method :greet_without_excitement, :greet
  alias_method :greet, :greet_with_excitement
end

tracy = DeprecatedPerson.new
tracy.greet # => "hi!!!!!"
tracy.greet_with_excitement # => "hi!!!!!"
tracy.greet_without_excitement # => "hi"

june = Person.new
june.greet # => "hi!!!!!"
june.greet_with_excitement # => "hi!!!!!"
june.greet_without_excitement # => "hi"

It is necessary to replace alias_method_chain because we use this gem in the
inventables/fbolt repo, and it may take some time to rewrite fbolt such that
this gem is no longer be a dependency.

Meanwhile, we are encountering deprecation warnings which are quite noisy.

Before upgrading from rails 5.0 to 5.1, we will have to address each of the
dependencies that still use alias_method_chain.
thomasjlee added a commit to inventables/nested_has_many_through that referenced this pull request Oct 23, 2021
…ails/rails#27035)

Apparently, defining methods such as :a_with_b and :a_without_b used to be a
common pattern in rails, so alias_method_chain was introduced to encapsulate
this (see: https://apidock.com/rails/ActiveSupport/CoreExtensions/Module/alias_method_chain).

Here is an example of how this works and how we can replace
alias_method_chain with alias_method:

class DeprecatedPerson
  def greet
    "hi"
  end

  def greet_with_excitement
    "#{greet_without_excitement}!!!!!"
  end

  alias_method_chain :greet, :excitement
end

class Person
  def greet
    "hi"
  end

  def greet_with_excitement
    "#{greet_without_excitement}!!!!!"
  end

  alias_method :greet_without_excitement, :greet
  alias_method :greet, :greet_with_excitement
end

tracy = DeprecatedPerson.new
tracy.greet # => "hi!!!!!"
tracy.greet_with_excitement # => "hi!!!!!"
tracy.greet_without_excitement # => "hi"

june = Person.new
june.greet # => "hi!!!!!"
june.greet_with_excitement # => "hi!!!!!"
june.greet_without_excitement # => "hi"

It is necessary to replace alias_method_chain because we use this gem in the
inventables/fbolt repo, and it may take some time to rewrite fbolt such that
this gem is no longer be a dependency.

Meanwhile, we are encountering deprecation warnings which are quite noisy.

Before upgrading from rails 5.0 to 5.1, we will have to address each of the
dependencies that still use alias_method_chain.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants