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

Remove set_query_available_custom_fields_to_project_level after validate hook from the AAC patch

Dombi Attilacadf65430863
diff --git a/app/models/projects/acts_as_customizable_patches.rb b/app/models/projects/acts_as_customizable_patches.rb
index 22c34dcdd0b..05fb4b360de 100644
--- a/app/models/projects/acts_as_customizable_patches.rb
+++ b/app/models/projects/acts_as_customizable_patches.rb
@@ -39,11 +39,6 @@ module Projects::ActsAsCustomizablePatches
dependent: :destroy, inverse_of: :project
has_many :project_custom_fields, through: :project_custom_field_project_mappings, class_name: "ProjectCustomField"
- # we need to reset the query_available_custom_fields_on_global_level already after validation
- # as the update service just calls .valid? and returns if invalid
- # after_save is not touched in this case which causes the flag to stay active
- after_validation :set_query_available_custom_fields_to_project_level
-
before_update :set_query_available_custom_fields_to_global_level
before_create :reject_section_scoped_validation_for_creation
diff --git a/app/services/projects/concerns/reset_global_query_after_validate_hook.rb b/app/services/projects/concerns/reset_global_query_after_validate_hook.rb
index 3c7855fda9d..3333e6b17b4 100644
--- a/app/services/projects/concerns/reset_global_query_after_validate_hook.rb
+++ b/app/services/projects/concerns/reset_global_query_after_validate_hook.rb
@@ -31,6 +31,10 @@ module Projects::Concerns
private
def after_validate(params, service_call)
+ # we need to reset the query_available_custom_fields_on_global_level already after validation
+ # as the update service just calls .valid? and returns if invalid
+ # after_save is not touched in this case which causes the flag to stay active
+ model = service_call.result
model._query_available_custom_fields_on_global_level = nil
super