File zammad-fix-rack-compatibility.patch of Package zammad
From 36a7d43d312e1c97cd9e2d129b60616de5cac368 Mon Sep 17 00:00:00 2001
From: Andreas Schneider <asn@cryptomilk.org>
Date: Tue, 24 Feb 2026 09:33:04 +0100
Subject: [PATCH] Fix Rack compatibility for newer Rack versions
Rack::Utils.add_cookie_to_header has been deprecated and removed in
version 3.10.
This patch makes the monkey-patch conditional - it only applies if the
method exists, allowing compatibility with both Rack 2.x and 3.x+.
---
lib/core_ext/rack/utils.rb | 20 +++++++++++++-------
1 file changed, 13 insertions(+), 7 deletions(-)
diff --git a/lib/core_ext/rack/utils.rb b/lib/core_ext/rack/utils.rb
index 2b98f0e139..36b638d81a 100644
--- a/lib/core_ext/rack/utils.rb
+++ b/lib/core_ext/rack/utils.rb
@@ -7,16 +7,22 @@ module Rack
module_function
- singleton_class.alias_method :original_add_cookie_to_header, :add_cookie_to_header
+ # Only apply monkey patch if the method exists (Rack 2.x compatibility)
+ if Rack::Utils.respond_to?(:add_cookie_to_header)
+ singleton_class.alias_method :original_add_cookie_to_header, :add_cookie_to_header
- # https://github.com/rack/rack/blob/2.2.3/lib/rack/session/utils.rb#L223-L262
- def add_cookie_to_header(header, key, value)
+ # https://github.com/rack/rack/blob/2.2.3/lib/rack/session/utils.rb#L223-L262
+ def add_cookie_to_header(header, key, value)
- if value.is_a?(Hash)
- value[:secure] = ::Session.secure_flag?
- end
+ if value.is_a?(Hash)
+ value[:secure] = ::Session.secure_flag?
+ end
- original_add_cookie_to_header(header, key, value)
+ original_add_cookie_to_header(header, key, value)
+ end
+ else
+ # Rack 3.1 or newer - method removed, skip monkey patch
+ Rails.logger.info "Rack::Utils.add_cookie_to_header not found, skipping secure cookie monkey patch" if defined?(Rails.logger)
end
end
end
--
2.53.0