diff --git a/app/models/sessions/active_record.rb b/app/models/sessions/active_record.rb index 91ee388cb24a..82a6c387ede1 100644 --- a/app/models/sessions/active_record.rb +++ b/app/models/sessions/active_record.rb @@ -51,5 +51,9 @@ class ActiveRecord < ::ApplicationRecord def readonly? true end + + def data + SqlBypass.deserialize(super) + end end end diff --git a/app/models/sessions/sql_bypass.rb b/app/models/sessions/sql_bypass.rb index 2adcefc4a3c9..4bffa3929477 100644 --- a/app/models/sessions/sql_bypass.rb +++ b/app/models/sessions/sql_bypass.rb @@ -44,17 +44,28 @@ class << self # @param session_id [String] The session ID as found in the `_open_project_session` cookie # @return [Hash] The saved session data (user_id, updated_at, etc.) or nil if no session was found. def lookup_data(session_id) + rack_session = Rack::Session::SessionId.new(session_id) if Rails.application.config.session_store == ActionDispatch::Session::ActiveRecordStore - find_by_session_id(session_id)&.data + find_by_session_id(rack_session.private_id)&.data else session_store = Rails.application.config.session_store.new nil, {} _id, data = session_store.instance_eval do - find_session({}, Rack::Session::SessionId.new(session_id)) + find_session({}, rack_session) end data.presence end end + + ## + # Ensure we're not memoizing the connection + def connection + ::ActiveRecord::Base.connection + end + + def connection_pool + ::ActiveRecord::Base.connection_pool + end end ##