Uploaded image for project: 'Mongoid'
  1. Mongoid
  2. MONGOID-5490

Deprecate and remove use_activesupport_time_zone (should always be true)

    • Type: Icon: Improvement Improvement
    • Resolution: Fixed
    • Priority: Icon: Unknown Unknown
    • 8.1.0
    • Affects Version/s: None
    • Component/s: None
    • None

      The Mongoid option "use_activesupport_time_zone" controls whether Ruby-native, system-TZ-based APIs such as Time.local / getlocal are used vs. ActiveSupport's Time.zone.local.

      Importantly, "use_activesupport_time_zone" does NOT control whether to use UTC versus time zones.

      Time.local is bad because it relies on the system's TZ setting and cannot be changed at runtime. In 100% cases, users should be using ActiveSupport's timezone model, and since Mongoid already requires ActiveSupport, there is no reason not to use it. (Perhaps there still an argument for it 10 years ago, but in 2022 there is not.)

       

      I propose the following:

      1. In Mongoid 8.1, deprecate use_activesupport_time_zone (print warning during initialization) and deprecate related methods like Time.configured.

      2. In Mongoid 9.0, remove the deprecated options.

      (Note it is easy to migrate use_activesupport_time_zone from false --> true by adding the line Time.zone = <system TZ> in one's app initializer.)

            Assignee:
            jamis.buck@mongodb.com Jamis Buck
            Reporter:
            shields@tablecheck.com Johnny Shields
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: