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

extend comment to clarify intend

ulferts0c6d2a663f1e
diff --git a/app/services/work_packages/update_service.rb b/app/services/work_packages/update_service.rb
index c8dcfe5bd0c..61f36a72fe7 100644
--- a/app/services/work_packages/update_service.rb
+++ b/app/services/work_packages/update_service.rb
@@ -160,6 +160,9 @@ class WorkPackages::UpdateService < ::BaseServices::BaseCallable
if work_package.parent_id_changed?
# HACK: we need to persist the parent relation before rescheduling the parent
# and the former parent since we rely on the database for scheduling.
+ # The following will update the parent_id of the work package without that being noticed by the
+ # work package instance (work_package) that is already instantiated. That way, the change can be rolled
+ # back without any side effects to the instance (e.g. dirty tracking).
WorkPackage.where(id: work_package.id).update_all(parent_id: work_package.parent_id)
work_package.rebuild! # using the ClosureTree#rebuild! method to update the transitive hierarchy information
end