Allow destroying a custom field even with invalid cost reports

Fixes https://community.openproject.com/work_packages/24184
pull/6827/head
Oliver Günther 8 years ago
parent 4ba819e9df
commit eaba43d8f1
No known key found for this signature in database
GPG Key ID: 88872239EB414F99
  1. 18
      lib/open_project/reporting/patches/custom_fields_controller_patch.rb

@ -34,13 +34,17 @@ module OpenProject::Reporting::Patches
def destroy_with_custom_fields
id = @custom_field.id
reports = CostQuery.where("serialized LIKE '%CustomField#{id}%'")
remove_custom_field_from_cost_report(reports, id)
remove_custom_field_from_session(id)
destroy_without_custom_fields
begin
reports = CostQuery.where("serialized LIKE '%CustomField#{id}%'")
remove_custom_field_from_cost_report(reports, id)
remove_custom_field_from_session(id)
rescue => e
Rails.logger.error "Failed to remove custom_field #{id} from custom queries. " \
"#{e.class}: #{e.message}"
ensure
destroy_without_custom_fields
end
end
private

Loading…
Cancel
Save