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 memoization in Queries::Projects::Selects::CustomField#custom_field

Ivan Kuchinde4c9818be42
diff --git a/app/models/queries/projects/selects/custom_field.rb b/app/models/queries/projects/selects/custom_field.rb
index d592f03ea7a..cdb19adb8d3 100644
--- a/app/models/queries/projects/selects/custom_field.rb
+++ b/app/models/queries/projects/selects/custom_field.rb
@@ -47,9 +47,11 @@ class Queries::Projects::Selects::CustomField < Queries::Selects::Base
end
def custom_field
- @custom_field ||= ProjectCustomField
- .visible
- .find_by(id: self.class.key.match(attribute)[1])
+ return @custom_field if defined?(@custom_field)
+
+ @custom_field = ProjectCustomField
+ .visible
+ .find_by(id: self.class.key.match(attribute)[1])
end
def available?