activesupport 5.2.0 → 5.2.1.rc1

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of activesupport might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d0110a46a9c1dae01d77cdc50139933d40baaed4e3d4d2aa316253350239f090
4
- data.tar.gz: ce05be98e3e753d72533c2002c42ab0ae9ce7bbcfd73b0a8a8a666c275fb4eb2
3
+ metadata.gz: 7442d72c95a432786415141473463adf87f484d28d3724e821a6aa894adc9daf
4
+ data.tar.gz: 674dda5800431fbb438197cb26c8549476fdad53c92f67f083a54e83356d4250
5
5
  SHA512:
6
- metadata.gz: b14730056fae2c1093e60f410cd2391fb18e590edcd7dee4e69a3c5493313154522edeb9e979fa038b3cdd897fb709c32719213e34c9fcaa3d2b8ab4f1c4a0cf
7
- data.tar.gz: 1bad53bfb9ea8ba7ef6af4a2e4af0f5e272dc712e3c0f8ac2593cb91a35653871eaa6abb6f01ac46f8a946e256241b4a0e00640e5abe4ecac1a43ff06465aceb
6
+ metadata.gz: 16733628761c9c045d1840a024c5163de247cd45fdae1a37f71f1917df954514b62da03c3611968a9bda70b6d503b829bc7f1d80d85258c304fbb35ac41f876a
7
+ data.tar.gz: eeacd40afbff738919197d3214ad98ff2c820468b8c397c1f158d3e8391c63069f1ebf03a600054199d16508940ac6b53f36a3baaf38eab3871e846cad3daaae
@@ -1,3 +1,28 @@
1
+ ## Rails 5.2.1.rc1 (July 30, 2018) ##
2
+
3
+ * Redis cache store: `delete_matched` no longer blocks the Redis server.
4
+ (Switches from evaled Lua to a batched SCAN + DEL loop.)
5
+
6
+ *Gleb Mazovetskiy*
7
+
8
+ * Fix bug where `ActiveSupport::Timezone.all` would fail when tzinfo data for
9
+ any timezone defined in `ActiveSupport::TimeZone::MAPPING` is missing.
10
+
11
+ *Dominik Sander*
12
+
13
+ * Fix bug where `ActiveSupport::Cache` will massively inflate the storage
14
+ size when compression is enabled (which is true by default). This patch
15
+ does not attempt to repair existing data: please manually flush the cache
16
+ to clear out the problematic entries.
17
+
18
+ *Godfrey Chan*
19
+
20
+ * Fix `ActiveSupport::Cache#read_multi` bug with local cache enabled that was
21
+ returning instances of `ActiveSupport::Cache::Entry` instead of the raw values.
22
+
23
+ *Jasom Lee*
24
+
25
+
1
26
  ## Rails 5.2.0 (April 09, 2018) ##
2
27
 
3
28
  * Caching: MemCache and Redis `read_multi` and `fetch_multi` speedup.
@@ -712,17 +712,14 @@ module ActiveSupport
712
712
  DEFAULT_COMPRESS_LIMIT = 1.kilobyte
713
713
 
714
714
  # Creates a new cache entry for the specified value. Options supported are
715
- # +:compress+, +:compress_threshold+, and +:expires_in+.
716
- def initialize(value, options = {})
717
- @value = value
718
- if should_compress?(options)
719
- compress!
720
- end
721
-
722
- @version = options[:version]
715
+ # +:compress+, +:compress_threshold+, +:version+ and +:expires_in+.
716
+ def initialize(value, compress: true, compress_threshold: DEFAULT_COMPRESS_LIMIT, version: nil, expires_in: nil, **)
717
+ @value = value
718
+ @version = version
723
719
  @created_at = Time.now.to_f
724
- @expires_in = options[:expires_in]
725
- @expires_in = @expires_in.to_f if @expires_in
720
+ @expires_in = expires_in && expires_in.to_f
721
+
722
+ compress!(compress_threshold) if compress
726
723
  end
727
724
 
728
725
  def value
@@ -754,17 +751,13 @@ module ActiveSupport
754
751
  # Returns the size of the cached value. This could be less than
755
752
  # <tt>value.size</tt> if the data is compressed.
756
753
  def size
757
- if defined?(@s)
758
- @s
754
+ case value
755
+ when NilClass
756
+ 0
757
+ when String
758
+ @value.bytesize
759
759
  else
760
- case value
761
- when NilClass
762
- 0
763
- when String
764
- @value.bytesize
765
- else
766
- @s = Marshal.dump(@value).bytesize
767
- end
760
+ @s ||= Marshal.dump(@value).bytesize
768
761
  end
769
762
  end
770
763
 
@@ -781,31 +774,35 @@ module ActiveSupport
781
774
  end
782
775
 
783
776
  private
784
- def should_compress?(options)
785
- if @value && options.fetch(:compress, true)
786
- compress_threshold = options.fetch(:compress_threshold, DEFAULT_COMPRESS_LIMIT)
787
- serialized_value_size = (@value.is_a?(String) ? @value : marshaled_value).bytesize
777
+ def compress!(compress_threshold)
778
+ case @value
779
+ when nil, true, false, Numeric
780
+ uncompressed_size = 0
781
+ when String
782
+ uncompressed_size = @value.bytesize
783
+ else
784
+ serialized = Marshal.dump(@value)
785
+ uncompressed_size = serialized.bytesize
786
+ end
787
+
788
+ if uncompressed_size >= compress_threshold
789
+ serialized ||= Marshal.dump(@value)
790
+ compressed = Zlib::Deflate.deflate(serialized)
788
791
 
789
- serialized_value_size >= compress_threshold
792
+ if compressed.bytesize < uncompressed_size
793
+ @value = compressed
794
+ @compressed = true
795
+ end
790
796
  end
791
797
  end
792
798
 
793
799
  def compressed?
794
- defined?(@compressed) ? @compressed : false
795
- end
796
-
797
- def compress!
798
- @value = Zlib::Deflate.deflate(marshaled_value)
799
- @compressed = true
800
+ defined?(@compressed)
800
801
  end
801
802
 
802
803
  def uncompress(value)
803
804
  Marshal.load(Zlib::Inflate.inflate(value))
804
805
  end
805
-
806
- def marshaled_value
807
- @marshaled_value ||= Marshal.dump(@value)
808
- end
809
806
  end
810
807
  end
811
808
  end
@@ -63,8 +63,9 @@ module ActiveSupport
63
63
  end
64
64
  end
65
65
 
66
- DELETE_GLOB_LUA = "for i, name in ipairs(redis.call('KEYS', ARGV[1])) do redis.call('DEL', name); end"
67
- private_constant :DELETE_GLOB_LUA
66
+ # The maximum number of entries to receive per SCAN call.
67
+ SCAN_BATCH_SIZE = 1000
68
+ private_constant :SCAN_BATCH_SIZE
68
69
 
69
70
  # Support raw values in the local cache strategy.
70
71
  module LocalCacheWithRaw # :nodoc:
@@ -232,12 +233,18 @@ module ActiveSupport
232
233
  # Failsafe: Raises errors.
233
234
  def delete_matched(matcher, options = nil)
234
235
  instrument :delete_matched, matcher do
235
- case matcher
236
- when String
237
- redis.with { |c| c.eval DELETE_GLOB_LUA, [], [namespace_key(matcher, options)] }
238
- else
236
+ unless String === matcher
239
237
  raise ArgumentError, "Only Redis glob strings are supported: #{matcher.inspect}"
240
238
  end
239
+ redis.with do |c|
240
+ pattern = namespace_key(matcher, options)
241
+ cursor = "0"
242
+ # Fetch keys in batches using SCAN to avoid blocking the Redis server.
243
+ begin
244
+ cursor, keys = c.scan(cursor, match: pattern, count: SCAN_BATCH_SIZE)
245
+ c.del(*keys) unless keys.empty?
246
+ end until cursor == "0"
247
+ end
241
248
  end
242
249
  end
243
250
 
@@ -287,7 +294,7 @@ module ActiveSupport
287
294
  # Failsafe: Raises errors.
288
295
  def clear(options = nil)
289
296
  failsafe :clear do
290
- if namespace = merged_options(options)[namespace]
297
+ if namespace = merged_options(options)[:namespace]
291
298
  delete_matched "*", namespace: namespace
292
299
  else
293
300
  redis.with { |c| c.flushdb }
@@ -8,10 +8,15 @@ module Enumerable
8
8
  # and fall back to the compatible implementation, but that's much slower than
9
9
  # just calling the compat method in the first place.
10
10
  if Enumerable.instance_methods(false).include?(:sum) && !((?a..?b).sum rescue false)
11
+ # :stopdoc:
12
+
11
13
  # We can't use Refinements here because Refinements with Module which will be prepended
12
14
  # doesn't work well https://bugs.ruby-lang.org/issues/13446
13
15
  alias :_original_sum_with_required_identity :sum
14
16
  private :_original_sum_with_required_identity
17
+
18
+ # :startdoc:
19
+
15
20
  # Calculates a sum from the elements.
16
21
  #
17
22
  # payments.sum { |p| p.price * p.tax_rate }
@@ -75,11 +75,14 @@ class Hash
75
75
  #
76
76
  # This method is also aliased as +to_param+.
77
77
  def to_query(namespace = nil)
78
- collect do |key, value|
78
+ query = collect do |key, value|
79
79
  unless (value.is_a?(Hash) || value.is_a?(Array)) && value.empty?
80
80
  value.to_query(namespace ? "#{namespace}[#{key}]" : key)
81
81
  end
82
- end.compact.sort! * "&"
82
+ end.compact
83
+
84
+ query.sort! unless namespace.to_s.include?("[]")
85
+ query.join("&")
83
86
  end
84
87
 
85
88
  alias_method :to_param, :to_query
@@ -1,10 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "uri"
4
- str = "\xE6\x97\xA5\xE6\x9C\xAC\xE8\xAA\x9E" # Ni-ho-nn-go in UTF-8, means Japanese.
5
- parser = URI::Parser.new
6
-
7
- unless str == parser.unescape(parser.escape(str))
4
+ if RUBY_VERSION < "2.6.0"
8
5
  require "active_support/core_ext/module/redefine_method"
9
6
  URI::Parser.class_eval do
10
7
  silence_redefinition_of_method :unescape
@@ -224,6 +224,8 @@ module ActiveSupport #:nodoc:
224
224
  Dependencies.require_or_load(file_name)
225
225
  end
226
226
 
227
+ # :doc:
228
+
227
229
  # Interprets a file using <tt>mechanism</tt> and marks its defined
228
230
  # constants as autoloaded. <tt>file_name</tt> can be either a string or
229
231
  # respond to <tt>to_path</tt>.
@@ -242,6 +244,8 @@ module ActiveSupport #:nodoc:
242
244
  Dependencies.depend_on(file_name, message)
243
245
  end
244
246
 
247
+ # :nodoc:
248
+
245
249
  def load_dependency(file)
246
250
  if Dependencies.load? && Dependencies.constant_watch_stack.watching?
247
251
  Dependencies.new_constants_in(Object) { yield }
@@ -94,6 +94,10 @@ module ActiveSupport
94
94
 
95
95
  private
96
96
  def arity_coerce(behavior)
97
+ unless behavior.respond_to?(:call)
98
+ raise ArgumentError, "#{behavior.inspect} is not a valid deprecation behavior."
99
+ end
100
+
97
101
  if behavior.arity == 4 || behavior.arity == -1
98
102
  behavior
99
103
  else
@@ -104,7 +104,7 @@ module ActiveSupport
104
104
  end
105
105
  end
106
106
 
107
- RAILS_GEM_ROOT = File.expand_path("../../../..", __dir__)
107
+ RAILS_GEM_ROOT = File.expand_path("../../../..", __dir__) + "/"
108
108
 
109
109
  def ignored_callstack(path)
110
110
  path.start_with?(RAILS_GEM_ROOT) || path.start_with?(RbConfig::CONFIG["rubylibdir"])
@@ -57,7 +57,7 @@ module ActiveSupport
57
57
 
58
58
  private
59
59
  def writing(contents)
60
- tmp_file = "#{content_path.basename}.#{Process.pid}"
60
+ tmp_file = "#{Process.pid}.#{content_path.basename.to_s.chomp('.enc')}"
61
61
  tmp_path = Pathname.new File.join(Dir.tmpdir, tmp_file)
62
62
  tmp_path.binwrite contents
63
63
 
@@ -9,8 +9,8 @@ module ActiveSupport
9
9
  module VERSION
10
10
  MAJOR = 5
11
11
  MINOR = 2
12
- TINY = 0
13
- PRE = nil
12
+ TINY = 1
13
+ PRE = "rc1"
14
14
 
15
15
  STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".")
16
16
  end
@@ -44,7 +44,7 @@ module ActiveSupport
44
44
  alias_method :method_name, :name
45
45
 
46
46
  include ActiveSupport::Testing::TaggedLogging
47
- include ActiveSupport::Testing::SetupAndTeardown
47
+ prepend ActiveSupport::Testing::SetupAndTeardown
48
48
  include ActiveSupport::Testing::Assertions
49
49
  include ActiveSupport::Testing::Deprecation
50
50
  include ActiveSupport::Testing::TimeHelpers
@@ -1,6 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "active_support/concern"
4
3
  require "active_support/callbacks"
5
4
 
6
5
  module ActiveSupport
@@ -19,11 +18,10 @@ module ActiveSupport
19
18
  # end
20
19
  # end
21
20
  module SetupAndTeardown
22
- extend ActiveSupport::Concern
23
-
24
- included do
25
- include ActiveSupport::Callbacks
26
- define_callbacks :setup, :teardown
21
+ def self.prepended(klass)
22
+ klass.include ActiveSupport::Callbacks
23
+ klass.define_callbacks :setup, :teardown
24
+ klass.extend ClassMethods
27
25
  end
28
26
 
29
27
  module ClassMethods
@@ -47,12 +45,10 @@ module ActiveSupport
47
45
  begin
48
46
  run_callbacks :teardown
49
47
  rescue => e
50
- error = e
48
+ self.failures << Minitest::UnexpectedError.new(e)
51
49
  end
52
50
 
53
51
  super
54
- ensure
55
- raise error if error
56
52
  end
57
53
  end
58
54
  end
@@ -280,7 +280,8 @@ module ActiveSupport
280
280
 
281
281
  def zones_map
282
282
  @zones_map ||= MAPPING.each_with_object({}) do |(name, _), zones|
283
- zones[name] = self[name]
283
+ timezone = self[name]
284
+ zones[name] = timezone if timezone
284
285
  end
285
286
  end
286
287
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activesupport
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.2.0
4
+ version: 5.2.1.rc1
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Heinemeier Hansson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-04-09 00:00:00.000000000 Z
11
+ date: 2018-07-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: i18n
@@ -331,8 +331,8 @@ homepage: http://rubyonrails.org
331
331
  licenses:
332
332
  - MIT
333
333
  metadata:
334
- source_code_uri: https://github.com/rails/rails/tree/v5.2.0/activesupport
335
- changelog_uri: https://github.com/rails/rails/blob/v5.2.0/activesupport/CHANGELOG.md
334
+ source_code_uri: https://github.com/rails/rails/tree/v5.2.1.rc1/activesupport
335
+ changelog_uri: https://github.com/rails/rails/blob/v5.2.1.rc1/activesupport/CHANGELOG.md
336
336
  post_install_message:
337
337
  rdoc_options:
338
338
  - "--encoding"
@@ -346,12 +346,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
346
346
  version: 2.2.2
347
347
  required_rubygems_version: !ruby/object:Gem::Requirement
348
348
  requirements:
349
- - - ">="
349
+ - - ">"
350
350
  - !ruby/object:Gem::Version
351
- version: '0'
351
+ version: 1.3.1
352
352
  requirements: []
353
353
  rubyforge_project:
354
- rubygems_version: 2.7.6
354
+ rubygems_version: 2.7.3
355
355
  signing_key:
356
356
  specification_version: 4
357
357
  summary: A toolkit of support libraries and Ruby core extensions extracted from the