Why this commit?
TimeWithZone instances were unexpectedly being rounded up.
What changes were made and why?
Internally, .to_f was being called on TimeWithZone instances.
This can lead to inaccuracies if Rationals are involved. Using .to_r
instead of .to_f will be more accurate, but it does come with a
slight computational cost.
By default, Dalli has two fallbacks if no server addresses are given:
- $MEMCACHE_SERVERS
- "127.0.0.1:11211"
However, MemCacheStore does its own check for addresses, and falls back
to "localhost:11211" if none are present.
This can lead to bugs in migrations from the deprecated :dalli_store
(provided by the Dalli) to :mem_cache_store:
```diff
-config.cache_store = :dalli_store # could be implicitly relying on $MEMCACHE_SERVERS
+config.cache_store = :mem_cache_store # ignores $MEMCACHE_SERVERS
```
By removing our own fallback and simply passing `nil` to Dalli::Client,
we get its fallback logic for free. Tests are added so we can detect if
this ever changes.
Devs may be running tests on a machine which provides $MEMCACHE_SERVERS
without a trailing port. We should allow for this when checking if
Memcache is working.
This reverts commit 2eb7aa111bbbf69fe89bdcd96b4839480e2ac076, reversing
changes made to 0b28f0c39c5b0a0009f1ea9d13ce97704e20c85b.
Rails backtrace cleaner needs to be able to return empty traces to
separate application code from the framework code and not report
exceptions that happen inside only framework code.
See
345de17caf/actionpack/lib/action_dispatch/middleware/exception_wrapper.rb (L72).
The Listen gem does not notify across process forks, and so forked
processes must re-create their listeners. `EventedFileUpdateChecker`
handled this in `updated?` by checking if `Process.pid` was different.
Because file updates may have occurred after the start of the fork but
before the call to `updated?`, `updated?` would always return true in
this case.
However, the above approach can result in unnecessary application
reloading, particularly when using Spring. That, in turn, can cause
unexpected and problematic behavior: #39431, #37591. This commit
changes listener re-creation to occur immediately after fork, and
changes `updated?` to return true only when necessary.
The Listen gem dispatches "file changed" events from a separate thread.
This thread holds a reference to the `changed` callback, and runs until
the listener is stopped. Thus, objects that are part of the `changed`
callback's scope cannot be garbage collected until the listener is
stopped.
This commit isolates the `changed` callback and associated scope in an
`EventedFileUpdateChecker::Core` instance. This ensures that the
`EventedFileUpdateChecker` instance can be garbage collected.
Additionally, this commit adds a finalizer to the
`EventedFileUpdateChecker` instance, which stops the listener and
ensures that the `EventedFileUpdateChecker::Core` instance can be
garbage collected.
When an `EventedFileUpdateChecker` instance detects a watched directory
that previously did not exist, it calls `shutdown!` and then `boot!` to
reinitialize its underlying listener. Prior to this commit, `shutdown!`
invoked `Listen.stop` which stops **all** listeners, globally. This
commit changes `shutdown!` to stop the checker's listener only.
Fixes#38174.
When given a key of invalid length, OpenSSL::Cipher raises a "key must
be X bytes" error. However, EncryptedFile keys are packed before they
are passed to OpenSSL::Cipher, so the actual length requirement is "2*X
characters".
This commit checks the key length, and raises a more helpful error if
the key length is invalid.
Closes#39528.