aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport
Commit message (Collapse)AuthorAgeFilesLines
* Use correct variable in `secure_compare!`yuuji.yaginuma2019-07-262-1/+14
| | | | | `Messages::Rotator` has `@on_rotation` not `@rotation`. https://github.com/rails/rails/blob/72bc0806a7b378cd544e8fbf7ab22d74b7913ffb/activesupport/lib/active_support/messages/rotator.rb#L11
* Fixup 64a430129fKasper Timm Hansen2019-07-251-3/+5
|
* Use binding.local_variable_get for `:for`Kasper Timm Hansen2019-07-251-5/+3
| | | | | | Simplifies the surrounding code outside `convert_value`. Ref: https://github.com/rails/rails/pull/36758
* let autoloaded? support modules with overridden names [closes #36757]Xavier Noria2019-07-253-3/+21
|
* Merge pull request #36318 from itsWill/fix_event_object_payloadRafael França2019-07-253-1/+24
|\ | | | | Merge payload for EventObject subscribers
| * Merge payload for EventObject subscribersGuilherme Mansur2019-05-223-1/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When instrumenting a block of code like: ```ruby ActiveSupport::Notifications.instrument("process_action.action_controller", raw_paylaod) do |payload| payload[:view_runtime] = render_view end ``` If we use an evented subscriber like so: ``` ruby ActiveSupport::Notifications.subscribe("process_action.action_controller", raw_payload) do |event| assert event.payload[:view_runtime] end ``` The code breaks because the underlying EventObject's payload does not have the `:view_runtime` key added during instrumentation. This is because the `EventedObject` subscriber calls the `finish` method with the `payload` of the event at the time it was pushed into the stack, before the block executes, but we want to call `finish` with the `payload` after the instrument block executes this way if the `payload` was modified during the block we have access to it. This is consistent with the other types of subscribers who don't have this bug.
* | Merge pull request #36412 from robotdana/compact_blankRafael Mendonça França2019-07-253-0/+75
|\ \ | | | | | | | | | Add compact_blank shortcut for reject(&:blank?)
| * | Add compact_blank shortcut for reject(&:blank?)Dana Sherson2019-06-053-0/+75
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | I frequently find myself having to .compact but for blank. which means on an array reject(&:blank?) (this is fine), or, on a hash `.reject { |_k, v| v.blank? }` which is slightly more frustrating and i usually write it as .reject(&:blank?) first and am confused when it's trying to check if the keys are blank. I've added the analagous .compact_blank! where there's a reject! to build on (there's also a reject! in Set, but there's no other core_ext touching Set so i've left that alone)
* | | Merge pull request #36758 from jturkel/feature/hash-optimizationRafael França2019-07-251-1/+3
|\ \ \ | | | | | | | | Avoid unnecessary hash allocation in HashWithIndifferentAccess#convert_value
| * | | Avoid hash allocation for HashWithIndifferentAccess#convert_value default ↵Joel Turkel2019-07-241-1/+3
| | | | | | | | | | | | | | | | options
* | | | Optimize DescendantsArray insertionsJean Boussier2019-07-251-2/+4
|/ / /
* | | Make ActiveSupport::Logger Fiber-safeSenya2019-07-243-1/+78
| | | | | | | | | | | | | | | Use Fiber.current.__id__ in ActiveSupport::Logger#local_level= in order to make log level local to Ruby Fibers in addition to Threads.
* | | Merge pull request #36434 from Edouard-chin/ec-securecompare-rotationRafael França2019-07-242-0/+96
|\ \ \ | | | | | | | | Introduce a new ActiveSupport::SecureCompareRotator class:
| * | | Introduce a new ActiveSupport::SecureCompareRotator class:Edouard CHIN2019-06-062-0/+96
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - This class is used to rotate a previously determined value to a new one before making the comparions. We use this at Shopify to rotate Basic Auth crendials but I can imagine other use cases. The implementation uses the same `Messages::Rotator` module than the MessageEncryptor/MessageVerifier class so it works exactly the same way. You can use it as follow: ```ruby rotator = ActiveSupport::SecureCompareRotator.new('new_production_value') rotator.rotate('previous_production_value') rotator.secure_compare!('previous_production_value') ```
* | | | Merge pull request #36370 from ptoomey3/masterRafael França2019-07-232-1/+13
|\ \ \ \ | | | | | | | | | | Add support for Proc based parameter filtering on arrays of values
| * | | | Update activesupport/test/parameter_filter_test.rb Patrick Toomey2019-07-231-1/+0
| | | | | | | | | | | | | | | | | | | | | | | | | Remove extra newline. Co-Authored-By: Rafael França <rafael@franca.dev>
| * | | | Use style consistent with surrounding codePatrick Toomey2019-05-311-3/+1
| | | | |
| * | | | Fix typoPatrick Toomey2019-05-311-1/+1
| | | | |
| * | | | Recursively process arrays consistentlyPatrick Toomey2019-05-311-1/+8
| | | | | | | | | | | | | | | | | | | | Based on the way parameters are currently processed, a parameter value of type Hash is recursively processed. For a value of type Array however, the current behavior is to simply return the original array, with no filtering. It is not clear what the expected behavior should be. But, doing nothing seems incorrect, since it bypasses custom Proc based parameter filtering all together for arrays of values. This change processes values of type Array consistently. We map over the values and recursively call value_for_key on them. This still works with values of type Hash, since value_for_key already knows how to process Hash values.
| * | | | Add failing test for array values and procsPatrick Toomey2019-05-311-0/+8
| | | | | | | | | | | | | | | | | | | | Based on the way parameters are currently processed, a parameter value of type Hash is recursively processed. For a value of type Array however, the current behavior is to simply return the original array, with no filtering. It is not clear what the expected behavior should be. But, doing nothing seems incorrect, since it bypasses custom Proc based parameter filtering all together for arrays of values. This change introduces a failing test in preparation to add logic that proposes one possible option for the expected behavior with Array values.
* | | | | Improve changelog entry, remove extraneous word [ci skip]Carlos Antonio da Silva2019-07-231-2/+2
| | | | |
* | | | | Remove changelog entry for backported changeGeorge Claghorn2019-07-221-7/+0
| | | | |
* | | | | Omit marshal_dump & _dump from delegate_missing_toAaron Lipman2019-07-173-2/+44
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Exclude missing marshal_dump and _dump methods from being delegated to an object's delegation target via the delegate_missing_to extension. This avoids unintentionally adding instance variables to an object during marshallization, should the delegation target be a method which would otherwise add them. In current versions of Ruby, a bug exists in the way objects are marshalled, allowing for instance variables to be added or removed during marshallization (see https://bugs.ruby-lang.org/issues/15968). This results in a corrupted serialized byte stream, causing an object's instance variables to "leak" into subsequent serialized objects during demarshallization. In Rails, this behavior may be triggered when marshalling an object that uses the delegate_missing_to extension, if the delegation target is a method which adds or removes instance variables to an object being marshalled - when calling Marshal.dump(object), Ruby's built in behavior will check whether the object responds to :marshal_dump or :_dump, which in turn triggers the delegation target method in the responds_to_missing? function defined in activesupport/lib/active_support/core_ext/module/delegation.rb While future versions of Ruby will resolve this bug by raising a RuntimeError, the underlying cause of this error may not be readily apparent when encountered by Rails developers. By excluding marshal_dump and _dump from being delegated to an object's target, this commit eliminates a potential cause of unexpected behavior and/or RuntimeErrors. Fixes #36522
* | | | | Revert "Make UTF-8 string requirement explicit for ↵Cliff Pruitt2019-07-172-15/+2
| | | | | | | | | | | | | | | | | | | | `ActiveSupport::Inflector.transliterate`"
* | | | | Merge pull request #36690 from cpruitt/make-parameterize-requires-utf-8-explicitEileen M. Uchitelle2019-07-172-2/+15
|\ \ \ \ \ | | | | | | | | | | | | Make UTF-8 string requirement explicit for `ActiveSupport::Inflector.transliterate`
| * | | | | Make UTF-8 string requirement explicit for `transliterate`Cliff Pruitt2019-07-162-2/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | It's noted in #34062 that String#parameterize will raise an `Encoding::CompatibilityError` if the string is not UTF-8 encoded. The error is raised as a result of passing the string to `.unicode_normalize`. This PR raises a higher level `ArgumentError` if the provided string is not UTF-8 and updates documentation to note the encoding requirement.
* | | | | | Merge pull request #36648 from louim/patch-1Rafael França2019-07-161-2/+2
|\ \ \ \ \ \ | |/ / / / / |/| | | | | Update message verifier documentation [ci skip]
| * | | | | Update message verifier documentation [ci skip]Louis-Michel Couture2019-07-101-2/+2
| | | | | | | | | | | | | | | | | | Generate method of ActiveSupport Message verifier implied that the message is encrypted, but the message is simply Base64-encoded.
* | | | | | Merge pull request #36667 from ↵Gannon McGibbon2019-07-161-0/+3
|\ \ \ \ \ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | gmcgibbon/clarify_logger_set_in_log_subscriber_docs Specify log subscribers need a logger set before they can receive events
| * | | | | | Specify log subscribers need a logger set before they can receive eventsGannon McGibbon2019-07-151-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The current example code for `ActiveSupport::LogSubscriber` mysteriously fails if you're using it outside of Rails. This helps clarify a logger needs to be set first before log subscribers can process events. [ci skip]
* | | | | | | Merge pull request #36685 from Shopify/as-depedencies-unhook-fixRafael França2019-07-161-3/+23
|\ \ \ \ \ \ \ | | | | | | | | | | | | | | | | Fix Loadable.exclude_from to also reset Kernel#require
| * | | | | | | Fix Loadable.exclude_from to also reset Kernel#requireJean Boussier2019-07-161-3/+23
| | | | | | | |
* | | | | | | | Merge pull request #36557 from ↵Matthew Draper2019-07-162-3/+41
|\ \ \ \ \ \ \ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | sikachu/fix-source-annotation-extractor-annotation Fix problem with accessing deprecated constant proxy's subclass
| * | | | | | | | Fix problem with accessing constant proxy subclassPrem Sichanugrist2019-07-052-3/+41
| | |_|_|_|/ / / | |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This commit fixes #36313. After #32065 moved `SourceAnnotationExtractor` into `Rails` module, it broke the ability to access `SourceAnnotationExtractor::Annotate` directly as user would get this error: TypeError: Rails::SourceAnnotationExtractor is not a class/module This commit fixes the issue by making `DeprecatedConstantProxy` to inherit from `Module` and then defines `method_missing` and `const_missing` to retain the previous functionality. Thank you Matthew Draper for the idea of how to fix the issue! [Prem Sichanugrist & Matthew Draper]
* | | | | | | | Merge pull request #36656 from Edouard-chin/ec-local-cache-referenceRafael França2019-07-152-1/+13
|\ \ \ \ \ \ \ \ | | | | | | | | | | | | | | | | | | Return a copy of the cache entry when local_cache exists:
| * | | | | | | | Return a copy of the cache entry when local_cache exists:Edouard CHIN2019-07-112-1/+13
| | |_|_|/ / / / | |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - When the local cache exists (during the request lifecycle), the entry returned from the LocalStore is passed as a reference which means mutable object can accidentaly get modified. This behaviour seems unnecessarily unsafe and is prone to issues like it happened in our application. This patch dup the `Entry` returned from the cache and dup it's internal value.
* | | | | | | | active_support/core_ext/object/duplicable is not in use hereRyuta Kamizono2019-07-161-1/+0
| |_|_|/ / / / |/| | | | | |
* | | | | | | Inline anemic log guardDavid Heinemeier Hansson2019-07-151-6/+3
| |_|/ / / / |/| | | | | | | | | | | | | | | | | This is the only use of it
* | | | | | Merge pull request #36658 from Shopify/duplicable-changesRyuta Kamizono2019-07-142-118/+8
|\ \ \ \ \ \ | | | | | | | | | | | | | | Remove dead code in duplicable.rb
| * | | | | | Implement UnboundMethod#duplicable?Jean Boussier2019-07-122-2/+11
| | | | | | |
| * | | | | | Remove dead code in duplicable.rbJean Boussier2019-07-111-120/+1
| | | | | | |
* | | | | | | active_support/deprecation is not in use hereAkira Matsuda2019-07-122-2/+0
| | | | | | |
* | | | | | | active_support/dependencies/autoload is already required via active_support.rbAkira Matsuda2019-07-122-5/+0
| | | | | | |
* | | | | | | Improve changelog entry, remove extraneous word [ci skip]Carlos Antonio da Silva2019-07-111-2/+2
|/ / / / / /
* / / / / / Do not use hard tabs in CHANGELOGs [ci skip]Ryuta Kamizono2019-07-111-6/+6
|/ / / / / | | | | | | | | | | | | | | | | | | | | | | | | | It doesn't work as indentation preperly. https://github.com/rails/rails/blob/ba7634d304008a4e6170fd701a2b7e75e1d83aea/activesupport/CHANGELOG.md
* | | | | Merge pull request #36443 from jhawthorn/as_parallelization_process_nameJohn Hawthorn2019-07-061-0/+11
|\ \ \ \ \ | | | | | | | | | | | | Set process title of parallelized test workers
| * | | | | Set process name of parallelized test workersJohn Hawthorn2019-06-071-0/+11
| |/ / / /
* | | | | bumps ZeitwerkXavier Noria2019-06-301-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | This version makes eager loading and autoloading consistent, as documented in the upgrading guide.
* | | | | Rely on Kernel require instead of self requireBenoit Tigeot2019-06-221-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | With this code (exctracted from derailed_benchmarks): ```ruby require "bundler/inline" gemfile(true) do source "https://rubygems.org" gem "rails", "~> 6.0.0.rc1", require: false end FILES = [ "rails/engine/configuration", "rails/source_annotation_extractor", "active_support/deprecation" ] module Kernel alias :original_require :require def require(file) Kernel.require(file) end class << self alias :original_require :require end end Kernel.define_singleton_method(:require) do |file| original_require(file) end FILES.each do |file| puts "requiring file: #{file}" require file end ``` It fails with Rails 6 and the change introduced by 32065 ``` requiring file: rails/engine/configuration requiring file: rails/source_annotation_extractor Traceback (most recent call last): 11: from repro_derailed.rb:33:in `<main>' 10: from repro_derailed.rb:33:in `each' 9: from repro_derailed.rb:35:in `block in <main>' 8: from repro_derailed.rb:21:in `require' 7: from repro_derailed.rb:30:in `block in <main>' 6: from repro_derailed.rb:30:in `require' 5: from /Users/benoit.tigeot/.rvm/gems/ruby-2.5.1/gems/railties-6.0.0.rc1/lib/rails/source_annotation_extractor.rb:8:in `<top (required)>' 4: from /Users/benoit.tigeot/.rvm/gems/ruby-2.5.1/gems/activesupport-6.0.0.rc1/lib/active_support/deprecation/proxy_wrappers.rb:10:in `new' 3: from /Users/benoit.tigeot/.rvm/gems/ruby-2.5.1/gems/activesupport-6.0.0.rc1/lib/active_support/deprecation/proxy_wrappers.rb:10:in `new' 2: from /Users/benoit.tigeot/.rvm/gems/ruby-2.5.1/gems/activesupport-6.0.0.rc1/lib/active_support/deprecation/proxy_wrappers.rb:125:in `initialize' 1: from /Users/benoit.tigeot/.rvm/gems/ruby-2.5.1/gems/activesupport-6.0.0.rc1/lib/active_support/deprecation/proxy_wrappers.rb:23:in `method_missing' /Users/benoit.tigeot/.rvm/gems/ruby-2.5.1/gems/activesupport-6.0.0.rc1/lib/active_support/deprecation/proxy_wrappers.rb:148:in `warn': private method `warn' called for nil:NilClass (NoMethodError) ``` Related: - https://github.com/schneems/derailed_benchmarks/pull/130 - https://github.com/rails/rails/pull/32065
* | | | | Indentation >>Akira Matsuda2019-06-221-6/+6
| | | | |