Skip to content

Commit

Permalink
Merge pull request #49624 from rails/rm-deprecations
Browse files Browse the repository at this point in the history
Remove all deprecated code
  • Loading branch information
rafaelfranca committed May 1, 2024
2 parents 20444dd + b35df00 commit 8808df6
Show file tree
Hide file tree
Showing 64 changed files with 355 additions and 1,621 deletions.
2 changes: 1 addition & 1 deletion Gemfile.lock
Expand Up @@ -377,7 +377,7 @@ GEM
path_expander (1.1.1)
pg (1.5.4)
prettier_print (1.2.1)
prism (0.19.0)
prism (0.27.0)
propshaft (0.8.0)
actionpack (>= 7.0.0)
activesupport (>= 7.0.0)
Expand Down
8 changes: 8 additions & 0 deletions activestorage/CHANGELOG.md
@@ -1,3 +1,11 @@
* Remove deprecated `config.active_storage.silence_invalid_content_types_warning`.

*Rafael Mendonça França*

* Remove deprecated `config.active_storage.replace_on_assign_to_many`.

*Rafael Mendonça França*

* Add support for custom `key` in `ActiveStorage::Blob#compose`.

*Elvin Efendiev*
Expand Down
16 changes: 0 additions & 16 deletions activestorage/lib/active_storage.rb
Expand Up @@ -365,22 +365,6 @@ module ActiveStorage

mattr_accessor :video_preview_arguments, default: "-y -vframes 1 -f image2"

def self.replace_on_assign_to_many
ActiveStorage.deprecator.warn("config.active_storage.replace_on_assign_to_many is deprecated and has no effect.")
end

def self.replace_on_assign_to_many=(value)
ActiveStorage.deprecator.warn("config.active_storage.replace_on_assign_to_many is deprecated and has no effect.")
end

def self.silence_invalid_content_types_warning
ActiveStorage.deprecator.warn("config.active_storage.silence_invalid_content_types_warning is deprecated and has no effect.")
end

def self.silence_invalid_content_types_warning=(value)
ActiveStorage.deprecator.warn("config.active_storage.silence_invalid_content_types_warning is deprecated and has no effect.")
end

module Transformers
extend ActiveSupport::Autoload

Expand Down
73 changes: 73 additions & 0 deletions activesupport/CHANGELOG.md
@@ -1,3 +1,64 @@
* Remove deprecated `ActiveSupport::Notifications::Event#children` and `ActiveSupport::Notifications::Event#parent_of?`.

*Rafael Mendonça França*

* Remove deprecated support to call the following methods without passing a deprecator:

- `deprecate`
- `deprecate_constant`
- `ActiveSupport::Deprecation::DeprecatedObjectProxy.new`
- `ActiveSupport::Deprecation::DeprecatedInstanceVariableProxy.new`
- `ActiveSupport::Deprecation::DeprecatedConstantProxy.new`
- `assert_deprecated`
- `assert_not_deprecated`
- `collect_deprecations`

*Rafael Mendonça França*

* Remove deprecated `ActiveSupport::Deprecation` delegation to instance.

*Rafael Mendonça França*

* Remove deprecated `SafeBuffer#clone_empty`.

*Rafael Mendonça França*

* Remove deprecated `#to_default_s` from `Array`, `Date`, `DateTime` and `Time`.

*Rafael Mendonça França*

* Remove deprecated support to passing `Dalli::Client` instances to `MemCacheStore`.

*Rafael Mendonça França*

* Remove deprecated `config.active_support.use_rfc4122_namespaced_uuids`.

*Rafael Mendonça França*

* Remove deprecated `config.active_support.remove_deprecated_time_with_zone_name`.

*Rafael Mendonça França*

* Remove deprecated `config.active_support.disable_to_s_conversion`.

*Rafael Mendonça França*

* Remove deprecated support to bolding log text with positional boolean in `ActiveSupport::LogSubscriber#color`.

*Rafael Mendonça França*

* Remove deprecated constants `ActiveSupport::LogSubscriber::CLEAR` and `ActiveSupport::LogSubscriber::BOLD`.

*Rafael Mendonça França*

* Remove deprecated support for `config.active_support.cache_format_version = 6.1`.

*Rafael Mendonça França*

* Remove deprecated `:pool_size` and `:pool_timeout` options for the cache storage.

*Rafael Mendonça França*

* Warn on tests without assertions.

`ActiveSupport::TestCase` now warns when tests do not run any assertions.
Expand Down Expand Up @@ -54,6 +115,18 @@

*Sean Doyle*

* Remove deprecated support for the pre-Ruby 2.4 behavior of `to_time` returning a `Time` object with local timezone.

*Rafael Mendonça França*

* Deprecate `config.active_support.to_time_preserves_timezone`.

*Rafael Mendonça França*

* Deprecate `DateAndTime::Compatibility.preserve_timezone`.

*Rafael Mendonça França*

* Yield instance to `Object#with` block

```ruby
Expand Down
14 changes: 6 additions & 8 deletions activesupport/lib/active_support.rb
Expand Up @@ -111,17 +111,15 @@ def self.cache_format_version=(value)
end

def self.to_time_preserves_timezone
DateAndTime::Compatibility.preserve_timezone
ActiveSupport.deprecator.warn(
"`config.active_support.to_time_preserves_timezone` has been deprecated and will be removed in Rails 7.3."
)
end

def self.to_time_preserves_timezone=(value)
unless value
ActiveSupport.deprecator.warn(
"Support for the pre-Ruby 2.4 behavior of to_time has been deprecated and will be removed in Rails 7.2."
)
end

DateAndTime::Compatibility.preserve_timezone = value
ActiveSupport.deprecator.warn(
"`config.active_support.to_time_preserves_timezone` has been deprecated and will be removed in Rails 7.3."
)
end

def self.utc_to_local_returns_utc_offset_times
Expand Down
28 changes: 1 addition & 27 deletions activesupport/lib/active_support/cache.rb
Expand Up @@ -52,7 +52,7 @@ module Strategy
autoload :LocalCache, "active_support/cache/strategy/local_cache"
end

@format_version = 6.1
@format_version = 7.0

class << self
attr_accessor :format_version
Expand Down Expand Up @@ -200,24 +200,6 @@ class << self
def retrieve_pool_options(options)
if options.key?(:pool)
pool_options = options.delete(:pool)
elsif options.key?(:pool_size) || options.key?(:pool_timeout)
pool_options = {}

if options.key?(:pool_size)
ActiveSupport.deprecator.warn(<<~MSG)
Using :pool_size is deprecated and will be removed in Rails 7.2.
Use `pool: { size: #{options[:pool_size].inspect} }` instead.
MSG
pool_options[:size] = options.delete(:pool_size)
end

if options.key?(:pool_timeout)
ActiveSupport.deprecator.warn(<<~MSG)
Using :pool_timeout is deprecated and will be removed in Rails 7.2.
Use `pool: { timeout: #{options[:pool_timeout].inspect} }` instead.
MSG
pool_options[:timeout] = options.delete(:pool_timeout)
end
else
pool_options = true
end
Expand Down Expand Up @@ -779,14 +761,6 @@ def clear(options = nil)
private
def default_serializer
case Cache.format_version
when 6.1
ActiveSupport.deprecator.warn <<~EOM
Support for `config.active_support.cache_format_version = 6.1` has been deprecated and will be removed in Rails 7.2.
Check the Rails upgrade guide at https://guides.rubyonrails.org/upgrading_ruby_on_rails.html#new-activesupport-cache-serialization-format
for more information on how to upgrade.
EOM
Cache::SerializerWithFallback[:marshal_6_1]
when 7.0
Cache::SerializerWithFallback[:marshal_7_0]
when 7.1
Expand Down
74 changes: 6 additions & 68 deletions activesupport/lib/active_support/cache/mem_cache_store.rb
Expand Up @@ -41,46 +41,6 @@ def self.supports_cache_versioning?

prepend Strategy::LocalCache

module DupLocalCache
class DupLocalStore < DelegateClass(Strategy::LocalCache::LocalStore)
def write_entry(_key, entry)
if entry.is_a?(Entry)
entry.dup_value!
end
super
end

def fetch_entry(key)
entry = super do
new_entry = yield
if entry.is_a?(Entry)
new_entry.dup_value!
end
new_entry
end
entry = entry.dup

if entry.is_a?(Entry)
entry.dup_value!
end

entry
end
end

private
def local_cache
if ActiveSupport::Cache.format_version == 6.1
if local_cache = super
DupLocalStore.new(local_cache)
end
else
super
end
end
end
prepend DupLocalCache

KEY_MAX_SIZE = 250
ESCAPE_KEY_CHARS = /[\x00-\x20%\x7F-\xFF]/n

Expand Down Expand Up @@ -114,7 +74,6 @@ def self.build_mem_cache(*addresses) # :nodoc:
#
# If no addresses are provided, but <tt>ENV['MEMCACHE_SERVERS']</tt> is defined, it will be used instead. Otherwise,
# +MemCacheStore+ will connect to localhost:11211 (the default memcached port).
# Passing a +Dalli::Client+ instance is deprecated and will be removed. Please pass an address instead.
def initialize(*addresses)
addresses = addresses.flatten
options = addresses.extract_options!
Expand All @@ -126,19 +85,12 @@ def initialize(*addresses)
unless [String, Dalli::Client, NilClass].include?(addresses.first.class)
raise ArgumentError, "First argument must be an empty array, address, or array of addresses."
end
if addresses.first.is_a?(Dalli::Client)
ActiveSupport.deprecator.warn(<<~MSG)
Initializing MemCacheStore with a Dalli::Client is deprecated and will be removed in Rails 7.2.
Use memcached server addresses instead.
MSG
@data = addresses.first
else
@mem_cache_options = options.dup
# The value "compress: false" prevents duplicate compression within Dalli.
@mem_cache_options[:compress] = false
(OVERRIDDEN_OPTIONS - %i(compress)).each { |name| @mem_cache_options.delete(name) }
@data = self.class.build_mem_cache(*(addresses + [@mem_cache_options]))
end

@mem_cache_options = options.dup
# The value "compress: false" prevents duplicate compression within Dalli.
@mem_cache_options[:compress] = false
(OVERRIDDEN_OPTIONS - %i(compress)).each { |name| @mem_cache_options.delete(name) }
@data = self.class.build_mem_cache(*(addresses + [@mem_cache_options]))
end

def inspect
Expand Down Expand Up @@ -226,20 +178,6 @@ def stats
end

private
def default_serializer
if Cache.format_version == 6.1
ActiveSupport.deprecator.warn <<~EOM
Support for `config.active_support.cache_format_version = 6.1` has been deprecated and will be removed in Rails 7.2.
Check the Rails upgrade guide at https://guides.rubyonrails.org/upgrading_ruby_on_rails.html#new-activesupport-cache-serialization-format
for more information on how to upgrade.
EOM
Cache::SerializerWithFallback[:passthrough]
else
super
end
end

# Read an entry from the cache.
def read_entry(key, **options)
deserialize_entry(read_serialized_entry(key, **options), **options)
Expand Down
23 changes: 0 additions & 23 deletions activesupport/lib/active_support/cache/serializer_with_fallback.rb
Expand Up @@ -63,28 +63,6 @@ def dumped?(dumped)
end
end

module Marshal61WithFallback
include SerializerWithFallback
extend self

MARSHAL_SIGNATURE = "\x04\x08".b.freeze

def dump(entry)
Marshal.dump(entry)
end

def dump_compressed(entry, threshold)
Marshal.dump(entry.compressed(threshold))
end

alias_method :_load, :marshal_load
public :_load

def dumped?(dumped)
dumped.start_with?(MARSHAL_SIGNATURE)
end
end

module Marshal70WithFallback
include SerializerWithFallback
extend self
Expand Down Expand Up @@ -165,7 +143,6 @@ def available?

SERIALIZERS = {
passthrough: PassthroughWithFallback,
marshal_6_1: Marshal61WithFallback,
marshal_7_0: Marshal70WithFallback,
marshal_7_1: Marshal71WithFallback,
message_pack: MessagePackWithFallback,
Expand Down
Expand Up @@ -104,8 +104,6 @@ def to_fs(format = :default)
end
end
alias_method :to_formatted_s, :to_fs
alias_method :to_default_s, :to_s
deprecate to_default_s: :to_s, deprecator: ActiveSupport.deprecator

# Returns a string that represents the array in XML by invoking +to_xml+
# on each element. Active Record collections delegate their representation
Expand Down
2 changes: 0 additions & 2 deletions activesupport/lib/active_support/core_ext/date/conversions.rb
Expand Up @@ -56,8 +56,6 @@ def to_fs(format = :default)
end
end
alias_method :to_formatted_s, :to_fs
alias_method :to_default_s, :to_s
deprecate to_default_s: :to_s, deprecator: ActiveSupport.deprecator

# Overrides the default inspect method with a human readable one, e.g., "Mon, 21 Feb 2005"
def readable_inspect
Expand Down
Expand Up @@ -4,15 +4,6 @@

module DateAndTime
module Compatibility
# If true, +to_time+ preserves the timezone offset of receiver.
#
# NOTE: With Ruby 2.4+ the default for +to_time+ changed from
# converting to the local system time, to preserving the offset
# of the receiver. For backwards compatibility we're overriding
# this behavior, but new apps will have an initializer that sets
# this to true, because the new behavior is preferred.
mattr_accessor :preserve_timezone, instance_writer: false, default: false

# Change the output of <tt>ActiveSupport::TimeZone.utc_to_local</tt>.
#
# When +true+, it returns local times with a UTC offset, with +false+ local
Expand All @@ -27,5 +18,17 @@ module Compatibility
# # With `utc_to_local_returns_utc_offset_times = true`, local time is returned with UTC offset:
# zone.utc_to_local(Time.utc(2000, 1)) # => 1999-12-31 19:00:00 -0500
mattr_accessor :utc_to_local_returns_utc_offset_times, instance_writer: false, default: false

def self.preserve_timezone
ActiveSupport.deprecator.warn(
"`DateAndTime::Compatibility.preserve_timezone` has been deprecated and will be removed in Rails 7.3."
)
end

def self.preserve_timezone=(value)
ActiveSupport.deprecator.warn(
"`DateAndTime::Compatibility.preserve_timezone=` has been deprecated and will be removed in Rails 7.3."
)
end
end
end

0 comments on commit 8808df6

Please sign in to comment.