Skip to content

Conversation

@cbliard
Copy link
Member

@cbliard cbliard commented Jan 6, 2026

Ticket

https://community.openproject.org/wp/70290

What are you trying to accomplish?

When a project is copied, and members are excluded from the copy (uncheck "Project members" in "Copy project" page), then all work packages having a user assigned should still be copied, and the user fields should be cleared.

What approach did you choose and why?

This fixes the regression introduced in 5ea185e: the possible_principal_id was run against the source project instead of the target project, leading to always return something.

Fix is to always run possible_principal_id against the target project.

This was not detected by the unit tests: original tests were taking the first work package of the copied project to check that the user field was nil, assuming the first work package would be the copy of the one having the user field set, but actually the work package was not copied, so another work package is picked and this one has all user fields nil because the original work package has all user fields nil.

The test was fixed by explicitly getting the copied work package using the subject of the original work package, and failing if the copied work package is not found.

Merge checklist

  • Added/updated tests
  • Added/updated documentation in Lookbook (patterns, previews, etc)
  • Tested major browsers (Chrome, Firefox, Edge, ...)

https://community.openproject.org/wp/70290

This fixes the regression introduced in 5ea185e: the
`possible_principal_id` was run against the source project instead of
the target project, leading to always return something.

Fix is to always run `possible_principal_id` against the target project.

This was not detected by the unit tests: original tests were taking the
first work package of the copied project to check that the user field
was nil, assuming the first work package would be the copy of the one
having the user field set, but actually the work package was not copied,
so another work package is picked and this one has all user fields nil
because the original work package has all user fields nil.

The test was fixed by explicitly getting the copied work package using
the subject of the original work package, and failing if the copied work
package is not found.
@cbliard cbliard added the bugfix label Jan 6, 2026
And remove the usage of `project_copy.work_packages[0]` which can lead
to false positives 😱 when there are more than one element copied.
@cbliard cbliard requested a review from ulferts January 6, 2026 15:40
@cbliard cbliard merged commit 63ae189 into release/17.0 Jan 7, 2026
17 checks passed
@cbliard cbliard deleted the bugfix/70290-project-copy-does-not-copy-work-packages-being-assigned-to-if-members-are-not-copied branch January 7, 2026 07:30
@github-actions github-actions bot locked and limited conversation to collaborators Jan 7, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Development

Successfully merging this pull request may close these issues.

3 participants