Project

General

Profile

Actions

Patch #39110

closed

Replacing request_store with ActiveSupport::CurrentAttributes

Patch #39110: Replacing request_store with ActiveSupport::CurrentAttributes

Added by Takashi Kato about 3 years ago. Updated almost 3 years ago.

Status:
Closed
Priority:
Normal
Category:
Code cleanup/refactoring
Target version:

Description

Redmine utilizes the request_store gem to maintain a record of currently logged-in users.
However, Rails itself offers an additional feature called ActiveSupport::CurrentAttributes leveraging this module, we can eliminate the reliance on request_store.

ActiveSupport::CurrentAttributes provides equivalent functionality to request_store, but its value is reset when an ActiveJob is executed. To address this, a callback has been introduced to preserve the value when ActiveJob is employed.
I'm sharing this post because I'm currently running Redmine on a new Rails version, and after applying the following pull request, "test/integration/sudo_mode_test.rb" began to fail in multiple instances.

Link to the pull request: https://github.com/rails/rails/pull/47092


Files


Related issues 1 (0 open — 1 closed)

Related to Redmine - Feature #36320: Migrate to Rails 7.2ClosedMarius BĂLTEANUActions

Updated by Marius BĂLTEANU about 3 years ago Actions #1

Updated by Marius BĂLTEANU about 3 years ago Actions #2

  • Category set to Code cleanup/refactoring
  • Assignee set to Marius BĂLTEANU
  • Target version set to 6.0.0

Updated by Marius BĂLTEANU about 3 years ago Actions #3

  • Status changed from New to Resolved

Patch committed, thanks!

Updated by Marius BĂLTEANU almost 3 years ago Actions #4

  • Status changed from Resolved to Closed

Updated by Mizuki ISHIKAWA almost 3 years ago Actions #5

Could you please correct the typo in r22473.

diff --git a/lib/redmine/sudo_mode.rb b/lib/redmine/sudo_mode.rb
index d73880937..8df6d48d7 100644
--- a/lib/redmine/sudo_mode.rb
+++ b/lib/redmine/sudo_mode.rb
@@ -225,7 +225,7 @@ module Redmine

     # Turn sudo mode back on
     def self.enable!
-      CurrentSUdoMode.disabled = nil
+      CurrentSudoMode.disabled = nil
     end

     def self.enabled?

Updated by Marius BĂLTEANU almost 3 years ago Actions #6

Mizuki ISHIKAWA wrote in #note-5:

Could you please correct the typo in r22473.
[...]

Thanks for pointing this out.

Updated by Mizuki ISHIKAWA almost 3 years ago Actions #7

Thank you for your prompt response.

Actions

Also available in: PDF Atom