rails 7.2.3
Active Support
-
Fix
Enumerable#soleto return the full tuple instead of just the first element of the tuple.Olivier Bellone
-
Fix parallel tests hanging when worker processes die abruptly.
Previously, if a worker process was killed (e.g., OOM killed,
kill -9) during parallel test execution, the test suite would hang forever waiting for the dead worker.Joshua Young
-
ActiveSupport::FileUpdateCheckerdoes not depend onTime.nowto prevent unnecessary reloads with time travel test helpersJan Grodowski
-
Fix
ActiveSupport::BroadcastLoggerfrom executing a block argument for each logger (tagged, info, etc.).Jared Armstrong
-
Fix
ActiveSupport::HashWithIndifferentAccess#transform_keys!removing defaults.Hartley McGuire
-
Fix
ActiveSupport::HashWithIndifferentAccess#tranform_keys!to handle collisions.If the transformation would result in a key equal to another not yet transformed one, it would result in keys being lost.
Before:
>> {a: 1, b: 2}.with_indifferent_access.transform_keys!(&:succ) => {"c" => 1}After:
>> {a: 1, b: 2}.with_indifferent_access.transform_keys!(&:succ) => {"c" => 1, "d" => 2}Jason T Johnson, Jean Boussier
-
Fix
ActiveSupport::Cache::MemCacheStore#read_multito handle network errors.This method specifically wasn't handling network errors like other codepaths.
Alessandro Dal Grande
-
Fix Active Support Cache
fetch_multiwhen local store is active.fetch_multinow properly yield to the provided block for missing entries that have been recorded as such in the local store.Jean Boussier
-
Fix execution wrapping to report all exceptions, including
Exception.If a more serious error like
SystemStackErrororNoMemoryErrorhappens, the error reporter should be able to report these kinds of exceptions.Gannon McGibbon
-
Fix
RedisCacheStoreandMemCacheStoreto also handle connection pool related errors.These errors are rescued and reported to
Rails.error.Jean Boussier
-
Fix
ActiveSupport::Cache#read_multito respect version expiry when using local cache.zzak
-
Fix
ActiveSupport::MessageVerifierandActiveSupport::MessageEncryptorconfiguration ofon_rotationcallback.verifier.rotate(old_secret).on_rotation { ... }Now both work as documented.
Jean Boussier
-
Fix
ActiveSupport::MessageVerifierto always be able to verify both URL-safe and URL-unsafe payloads.This is to allow transitioning seemlessly from either configuration without immediately invalidating all previously generated signed messages.
Jean Boussier, Florent Beaurain, Ali Sepehri
-
Fix
cache.fetchto honor the provided expiry when:race_condition_ttlis used.cache.fetch("key", expires_in: 1.hour, race_condition_ttl: 5.second) do "something" endIn the above example, the final cache entry would have a 10 seconds TTL instead of the requested 1 hour.
Dhia
-
Better handle procs with splat arguments in
set_callback.Radamés Roriz
-
Fix
String#mb_charsto not mutate the receiver.Previously it would call
force_encodingon the receiver, now it dups the receiver first.Jean Boussier
-
Improve
ErrorSubscriberto also mark error causes as reported.This avoid some cases of errors being reported twice, notably in views because of how errors are wrapped in
ActionView::Template::Error.Jean Boussier
-
Fix
Module#module_parent_nameto return the correct name after the module has been named.When called on an anonymous module, the return value wouldn't change after the module was given a name later by being assigned to a constant.
mod = Module.new mod.module_parent_name # => "Object" MyModule::Something = mod mod.module_parent_name # => "MyModule"Jean Boussier
-
Fix a bug in
ERB::Util.tokenizethat causes incorrect tokenization when ERB tags are preceeded by multibyte characters.Martin Emde
Active Model
-
Fix
has_secure_passwordto perform confirmation validation of the password even when blank.The validation was incorrectly skipped when the password only contained whitespace characters.
Fabio Sangiovanni
-
Handle missing attributes for
ActiveModel::Translation#human_attribute_name.zzak
-
Fix
ActiveModel::AttributeAssignment#assign_attributesto accept objects withouteach.Kouhei Yanagita
Active Record
-
Fix SQLite3 data loss during table alterations with CASCADE foreign keys.
When altering a table in SQLite3 that is referenced by child tables with
ON DELETE CASCADEforeign keys, ActiveRecord would silently delete all data from the child tables. This occurred because SQLite requires table recreation for schema changes, and during this process the original table is temporarily dropped, triggering CASCADE deletes on child tables.The root cause was incorrect ordering of operations. The original code wrapped
disable_referential_integrityinside a transaction, butPRAGMA foreign_keyscannot be modified inside a transaction in SQLite - attempting to do so simply has no effect. This meant foreign keys remained enabled during table recreation, causing CASCADE deletes to fire.The fix reverses the order to follow the official SQLite 12-step ALTER TABLE procedure:
disable_referential_integritynow wraps the transaction instead of being wrapped by it. This ensures foreign keys are properly disabled before the transaction starts and re-enabled after it commits, preventing CASCADE deletes while maintaining data integrity through atomic transactions.Ruy Rocha
-
Fix
belongs_toassociations not to clear the entire composite primary key.When clearing a
belongs_toassociation that references a model with composite primary key, only the optional part of the key should be cleared.zzak
-
Fix invalid records being autosaved when distantly associated records are marked for deletion.
Ian Terrell, axlekb AB
-
Prevent persisting invalid record.
Edouard Chin
-
Fix count with group by qualified name on loaded relation.
Ryuta Kamizono
-
Fix
sumwith qualified name on loaded relation.Chris Gunther
-
Fix prepared statements on mysql2 adapter.
Jean Boussier
-
Fix query cache for pinned connections in multi threaded transactional tests.
When a pinned connection is used across separate threads, they now use a separate cache store for each thread.
This improve accuracy of system tests, and any test using multiple threads.
Heinrich Lee Yu, Jean Boussier
-
Don't add
id_valueattribute alias when attribute/column with that name already exists.Rob Lewis
-
Fix false positive change detection involving STI and polymorhic has one relationships.
Polymorphic
has_onerelationships would always be considered changed when defined in a STI child class, causing nedless extra autosaves.David Fritsch
-
Fix stale associaton detection for polymophic
belong_to.Florent Beaurain, Thomas Crambert
-
Fix removal of PostgreSQL version comments in
structure.sqlfor latest PostgreSQL versions which include\restrict.Brendan Weibrecht
-
Fix
#mergewith#oror#andand a mixture of attributes and SQL strings resulting in an incorrect query.base = Comment.joins(:post).where(user_id: 1).where("recent = 1") puts base.merge(base.where(draft: true).or(Post.where(archived: true))).to_sqlBefore:
SELECT "comments".* FROM "comments"
INNER JOIN "posts" ON "posts"."id" = "comments"."post_id"
WHERE (recent = 1)
AND (
"comments"."user_id" = 1
AND (recent = 1)
AND "comments"."draft" = 1
OR "posts"."archived" = 1
)
```
After:
```sql
SELECT "comments".* FROM "comments"
INNER JOIN "posts" ON "posts"."id" = "comments"."post_id"
WHERE "comments"."user_id" = 1
AND (recent = 1)
AND (
"comments"."user_id" = 1
AND (recent = 1)
AND "comments"."draft" = 1
OR "posts"."archived" = 1
)
```
*Joshua Young*
* Fix inline `has_and_belongs_to_many` fixtures for tables with composite primary keys.
*fatkodima*
* Fix `annotate` comments to propagate to `update_all`/`delete_all`.
*fatkodima*
* Fix checking whether an unpersisted record is `include?`d in a strictly
loaded `has_and_belongs_to_many` association.
*Hartley McGuire*
* Fix inline has_and_belongs_to_many fixtures for tables with composite primary keys.
*fatkodima*
* `create_or_find_by` will now correctly rollback a transaction.
When using `create_or_find_by`, raising a ActiveRecord::Rollback error
in a `after_save` callback had no effect, the transaction was committed
and a record created.
*Edouard Chin*
* Gracefully handle `Timeout.timeout` firing during connection configuration.
Use of `Timeout.timeout` could result in improperly initialized database connection.
This could lead to a partially configured connection being used, resulting in various exceptions,
the most common being with the PostgreSQLAdapter raising `undefined method 'key?' for nil`
or `TypeError: wrong argument type nil (expected PG::TypeMap)`.
*Jean Boussier*
* The SQLite3 adapter quotes non-finite Numeric values like "Infinity" and "NaN".
*Mike Dalessio*
* Handle libpq returning a database version of 0 on no/bad connection in `PostgreSQLAdapter`.
Before, this version would be cached and an error would be raised during connection configuration when
comparing it with the minimum required version for the adapter. This meant that the connection could
never be successfully configured on subsequent reconnection attempts.
Now, this is treated as a connection failure consistent with libpq, raising a `ActiveRecord::ConnectionFailed`
and ensuring the version isn't cached, which allows the version to be retrieved on the next connection attempt.
*Joshua Young*, *Rian McGuire*
* Fix error handling during connection configuration.
Active Record wasn't properly handling errors during the connection configuration phase.
This could lead to a partially configured connection being used, resulting in various exceptions,
the most common being with the PostgreSQLAdapter raising `undefined method `key?' for nil`
or `TypeError: wrong argument type nil (expected PG::TypeMap)`.
*Jean Boussier*
* Fix a case where a non-retryable query could be marked retryable.
*Hartley McGuire*
* Handle circular references when autosaving associations.
*zzak*
* Prevent persisting invalid record.
*Edouard Chin*
* Fix support for PostgreSQL enum types with commas in their name.
*Arthur Hess*
* Fix inserts on MySQL with no RETURNING support for a table with multiple auto populated columns.
*Nikita Vasilevsky*
* Fix joining on a scoped association with string joins and bind parameters.
```ruby
class Instructor < ActiveRecord::Base
has_many :instructor_roles, -> { active }
end
class InstructorRole < ActiveRecord::Base
scope :active, -> {
joins("JOIN students ON instructor_roles.student_id = students.id")
.where(students { status: 1 })
}
end
Instructor.joins(:instructor_roles).first
```
The above example would result in `ActiveRecord::StatementInvalid` because the
`active` scope bind parameters would be lost.
*Jean Boussier*
* Fix a potential race condition with system tests and transactional fixtures.
*Sjoerd Lagarde*
* Fix count with group by qualified name on loaded relation.
*Ryuta Kamizono*
* Fix sum with qualified name on loaded relation.
*Chris Gunther*
* Fix autosave associations to no longer validated unmodified associated records.
Active Record was incorrectly performing validation on associated record that
weren't created nor modified as part of the transaction:
```ruby
Post.create!(author: User.find(1)) # Fail if user is invalid
```
*Jean Boussier*
* Remember when a database connection has recently been verified (for
two seconds, by default), to avoid repeated reverifications during a
single request.
This should recreate a similar rate of verification as in Rails 7.1,
where connections are leased for the duration of a request, and thus
only verified once.
*Matthew Draper*
* Fix prepared statements on mysql2 adapter.
*Jean Boussier*
* Fix a race condition in `ActiveRecord::Base#method_missing` when lazily defining attributes.
If multiple thread were concurrently triggering attribute definition on the same model,
it could result in a `NoMethodError` being raised.
*Jean Boussier*
* Fix MySQL default functions getting dropped when changing a column's nullability.
*Bastian Bartmann*
* Fix `add_unique_constraint`/`add_check_constraint`/`/`add_foreign_key` to be revertible when
given invalid options.
*fatkodima*
* Fix asynchronous destroying of polymorphic `belongs_to` associations.
*fatkodima*
* NOT VALID constraints should not dump in `create_table`.
*Ryuta Kamizono*
* Fix finding by nil composite primary key association.
*fatkodima*
* Fix parsing of SQLite foreign key names when they contain non-ASCII characters
*Zacharias Knudsen*
* Fix parsing of MySQL 8.0.16+ CHECK constraints when they contain new lines.
*Steve Hill*
* Ensure normalized attribute queries use `IS NULL` consistently for `nil` and normalized `nil` values.
*Joshua Young*
* Restore back the ability to pass only database name for `DATABASE_URL`.
*fatkodima*
* Fix `order` with using association name as an alias.
*Ryuta Kamizono*
* Improve invalid argument error for with.
*Ryuta Kamizono*
* Deduplicate `with` CTE expressions.
*fatkodima*
## Action View
* Fix `javascript_include_tag` `type` option to accept either strings and symbols.
```ruby
javascript_include_tag "application", type: :module
javascript_include_tag "application", type: "module"
```
Previously, only the string value was recoginized.
*Jean Boussier*
* Fix `excerpt` helper with non-whitespace separator.
*Jonathan Hefner*
* Respect `html_options[:form]` when `collection_checkboxes` generates the
hidden `<input>`.
*Riccardo Odone*
* Layouts have access to local variables passed to `render`.
This fixes #31680 which was a regression in Rails 5.1.
*Mike Dalessio*
* Argument errors related to strict locals in templates now raise an
`ActionView::StrictLocalsError`, and all other argument errors are reraised as-is.
Previously, any `ArgumentError` raised during template rendering was swallowed during strict
local error handling, so that an `ArgumentError` unrelated to strict locals (e.g., a helper
method invoked with incorrect arguments) would be replaced by a similar `ArgumentError` with an
unrelated backtrace, making it difficult to debug templates.
Now, any `ArgumentError` unrelated to strict locals is reraised, preserving the original
backtrace for developers.
Also note that `ActionView::StrictLocalsError` is a subclass of `ArgumentError`, so any existing
code that rescues `ArgumentError` will continue to work.
Fixes #52227.
*Mike Dalessio*
* Fix stack overflow error in dependency tracker when dealing with circular dependencies
*Jean Boussier*
* Fix a crash in ERB template error highlighting when the error occurs on a
line in the compiled template that is past the end of the source template.
*Martin Emde*
* Improve reliability of ERB template error highlighting.
Fix infinite loops and crashes in highlighting and
improve tolerance for alternate ERB handlers.
*Martin Emde*
## Action Pack
* Submit test requests using `as: :html` with `Content-Type: x-www-form-urlencoded`
*Sean Doyle*
* Address `rack 3.2` deprecations warnings.
```
warning: Status code :unprocessable_entity is deprecated and will be removed in a future version of Rack.
Please use :unprocessable_content instead.
```
Rails API will transparently convert one into the other for the forseable future.
*Earlopain*, *Jean Boussier*
* Always return empty body for HEAD requests in `PublicExceptions` and
`DebugExceptions`.
This is required by `Rack::Lint` (per RFC9110).
*Hartley McGuire*
* Fix `url_for` to handle `:path_params` gracefully when it's not a `Hash`.
Prevents various security scanners from causing exceptions.
*Martin Emde*
* Fix `ActionDispatch::Executor` to unwrap exceptions like other error reporting middlewares.
*Jean Boussier*
* Fix NoMethodError when a non-string CSRF token is passed through headers.
*Ryan Heneise*
* Fix invalid response when rescuing `ActionController::Redirecting::UnsafeRedirectError` in a controller.
*Alex Ghiculescu*
## Active Job
* Include the actual Active Job locale when serializing rather than I18n locale.
*Adrien S*
* Avoid crashing in Active Job logger when logging enqueueing errors
`ActiveJob.perform_all_later` could fail with a `TypeError` when all
provided jobs failed to be enqueueed.
*Efstathios Stivaros*
## Action Mailer
* No changes.
## Action Cable
* Fixed compatibility with `redis` gem `5.4.1`
*Jean Boussier*
* Fixed a possible race condition in `stream_from`.
*OuYangJinTing*
* Ensure the Postgresql adapter always use a dedicated connection even during system tests.
Fix an issue with the Action Cable Postgresql adapter causing deadlock or various weird
pg client error during system tests.
*Jean Boussier*
## Active Storage
* Fix `config.active_storage.touch_attachment_records` to work with eager loading.
*fatkodima*
* A Blob will no longer autosave associated Attachment.
This fixes an issue where a record with an attachment would have
its dirty attributes reset, preventing your `after commit` callbacks
on that record to behave as expected.
Note that this change doesn't require any changes on your application
and is supposed to be internal. Active Storage Attachment will continue
to be autosaved (through a different relation).
*Edouard-chin*
## Action Mailbox
* No changes.
## Action Text
* No changes.
## Railties
* Use `secret_key_base` from ENV or credentials when present locally.
When ENV["SECRET_KEY_BASE"] or
`Rails.application.credentials.secret_key_base` is set for test or
development, it is used for the `Rails.config.secret_key_base`,
instead of generating a `tmp/local_secret.txt` file.
*Petrik de Heus*
## Guides
* No changes.