Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

Fix connection being memoized in sqlbypass class

Oliver Güntheraeec219bfbe4
diff --git a/app/models/sessions/sql_bypass.rb b/app/models/sessions/sql_bypass.rb
index 4bffa392947..6f7f1a8c7e7 100644
--- a/app/models/sessions/sql_bypass.rb
+++ b/app/models/sessions/sql_bypass.rb
@@ -57,17 +57,19 @@ module Sessions
end
end
- ##
- # Ensure we're not memoizing the connection
- def connection
- ::ActiveRecord::Base.connection
- end
-
def connection_pool
::ActiveRecord::Base.connection_pool
end
+
+ def connection
+ ::ActiveRecord::Base.connection
+ end
end
+ # Ensure we use our own class methods for delegation of the connection
+ # otherwise the memoized superclass is being used
+ delegate :connection, :connection_pool, to: :class
+
##
# Save while updating the user_id reference and updated_at column
def save
@@ -107,6 +109,7 @@ module Sessions
SQL
end
+
def update!
connection.update <<~SQL, 'Update session'
UPDATE sessions