Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

39 legacy connection handler #40

Merged
merged 5 commits into from
Jan 30, 2024
Merged

39 legacy connection handler #40

merged 5 commits into from
Jan 30, 2024

Conversation

jpmedforth
Copy link
Contributor

No description provided.

@@ -8,7 +8,7 @@
ActiveSupport::KeyGenerator.hash_digest_class = OpenSSL::Digest::SHA256 if ActiveSupport::KeyGenerator.respond_to?(:hash_digest_class=)
ActiveSupport::MessageEncryptor.use_authenticated_message_encryption = true
ActiveSupport::IsolatedExecutionState.isolation_level = :thread if defined?(ActiveSupport::IsolatedExecutionState)
Digest::UUID.use_rfc4122_namespaced_uuids = true if Digest::UUID.respond_to?(:use_rfc4122_namespaced_uuids=)
# Digest::UUID.use_rfc4122_namespaced_uuids = true if Digest::UUID.respond_to?(:use_rfc4122_namespaced_uuids=)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure about this one. Checking....

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's fine, activesupport is using SecureRandom.uuid nowadays, this is legacy from when it used Digest::UUID directly. This changed in 7.1, but OK to keep as we support older activesupport versions too

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just add a comment saying, this is legacy, removed with Rails 7.1 so we know in the future

@@ -8,7 +8,7 @@
ActiveSupport::KeyGenerator.hash_digest_class = OpenSSL::Digest::SHA256 if ActiveSupport::KeyGenerator.respond_to?(:hash_digest_class=)
ActiveSupport::MessageEncryptor.use_authenticated_message_encryption = true
ActiveSupport::IsolatedExecutionState.isolation_level = :thread if defined?(ActiveSupport::IsolatedExecutionState)
Digest::UUID.use_rfc4122_namespaced_uuids = true if Digest::UUID.respond_to?(:use_rfc4122_namespaced_uuids=)
# Digest::UUID.use_rfc4122_namespaced_uuids = true if Digest::UUID.respond_to?(:use_rfc4122_namespaced_uuids=)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's fine, activesupport is using SecureRandom.uuid nowadays, this is legacy from when it used Digest::UUID directly. This changed in 7.1, but OK to keep as we support older activesupport versions too

@@ -43,12 +43,6 @@ def call(exception, *)
ActiveRecord::Base.default_timezone = :utc
end

if ActiveRecord.respond_to?(:legacy_connection_handling=)
ActiveRecord.legacy_connection_handling = false
else
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this be an elsif. same here, we should support versions older than 7.1

@@ -43,14 +43,13 @@ def app
if ActiveSupport::VERSION::MAJOR >= 7
expect(ActiveSupport::KeyGenerator.hash_digest_class).to be(OpenSSL::Digest::SHA256)
expect(ActiveSupport::IsolatedExecutionState.isolation_level).to be(:thread)
expect(Digest::UUID.use_rfc4122_namespaced_uuids).to be(true)
# expect(Digest::UUID.use_rfc4122_namespaced_uuids).to be(true)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove the line completely

@@ -8,7 +8,7 @@
ActiveSupport::KeyGenerator.hash_digest_class = OpenSSL::Digest::SHA256 if ActiveSupport::KeyGenerator.respond_to?(:hash_digest_class=)
ActiveSupport::MessageEncryptor.use_authenticated_message_encryption = true
ActiveSupport::IsolatedExecutionState.isolation_level = :thread if defined?(ActiveSupport::IsolatedExecutionState)
Digest::UUID.use_rfc4122_namespaced_uuids = true if Digest::UUID.respond_to?(:use_rfc4122_namespaced_uuids=)
# Digest::UUID.use_rfc4122_namespaced_uuids = true if Digest::UUID.respond_to?(:use_rfc4122_namespaced_uuids=)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just add a comment saying, this is legacy, removed with Rails 7.1 so we know in the future

No longer supporting ruby2.7 (eol)
Adding github checks against ruby3.3.
@@ -43,6 +44,15 @@ def call(exception, *)
ActiveRecord::Base.default_timezone = :utc
end

# legacy_connection_handling was deprecated in ActiveRecord 7
if ActiveRecord::VERSION::MAJOR < 7
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not just elsif ActiveRecord::Base.respond_to?(:legacy_connection_handling=). seems more consistent

Copy link
Contributor Author

@jpmedforth jpmedforth Jan 30, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So it's still in the code.
https://github.com/rails/rails/blob/v7.1.3/activerecord/lib/active_record.rb#L246

So respond_to still returns true, then it raises an error. I thought best not to try at all if the version was too high.

@dim dim merged commit f172968 into main Jan 30, 2024
10 checks passed
@dim dim deleted the 39-legacy-connection-handler branch January 30, 2024 09:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

legacy_connection_handling setter was deprecated in 7.0 and removed in 7.1
2 participants