Defect #17580
closedAfter copying a task, setting the parent as the orignal task's parent triggers an error
0%
Description
Steps for repro:
1. Create an issue (1), and add a sub-issue (2) to it
2. Copy this sub-issue (creates issue 3)
3. Edit issue 3, set issue 1 as its parent
Result: We get an error that Parent Issue is invalid
4. Copy (2), and while in edit mode, define issue 1 as the parent
Result: this relationship is accepted
5. Create sub-issue (4) of issue 1
6. Display issue 4, add issue 2 as a related issue
Result: this relationship is accepted
Expected result: the behavior should be consistent. As far as I'm concerned, I do not see what would justify that "relations" would be forbidden inside the parent-children tree, so the faulty behavior would be the first result (Parent issue invalid) but I might be missing some cases.
Notes :
1) This is related to #12893 (obviously on purpose, see line 216 of app/models/issue.rb:
self.attributes = issue.attributes.dup.except("id", "root_id", "parent_id", "lft", "rgt", "created_on", "updated_on")
2) The current behaviour for 1st result is on purpose: the error message is triggered by line 600 of issue.rb:
elsif (@parent_issue != parent) && (all_dependent_issues.include?(@parent_issue) || @parent_issue.all_dependent_issues.include?(self))
which definitely parses parents, children, cousins, etc., but also related issues.
Files
Related issues
Updated by Toshi MARUYAMA over 10 years ago
- Related to Defect #12893: Copying an issue does not copy parent task id added
Updated by Olivier Houdas about 9 years ago
- File 17580-RM-3.1.1.patch 17580-RM-3.1.1.patch added
I fell on this issue again one year later, and so I decided to have a deeper look at the situation.
If we consider that
Parent / \ Child1 <--> Child2
is a circular relationship, then it should be tested when adding a relation as well, and not only when modifying the parent id.
For this, we should add a test in /app/models/issue_relation.rb.
Now, when there is no relation added (Redmine configuration setting set to Do not link copied issues), we should not cancel the copy of the parent_id, as mentioned in #12893. For this, I suggest to take this setting into account and copy the parent_id attribute conditionally.
I attached a patch which implements those remarks.
You will note that the failure of adding the link after saving the copied issue (which comes after validation, and therefore relies on a different validation than when changing the parent_id), results only in an ERROR in the log, and not in a flashed error. Feel free to modify this behavior if you feel this is necessary.
Could this come into a release soon?
Thanks
Updated by Toshi MARUYAMA about 9 years ago
- Related to Defect #13654: Can't set parent issue when issue relations among child issues are present added
Updated by Jean-Philippe Lang almost 9 years ago
- Status changed from New to Closed
- Assignee set to Jean-Philippe Lang
- Target version set to 3.3.0
- Resolution set to Fixed