Defect #28765

Copying an issue fails if the issue is watched by a locked user

Added by Ayami Yasuoka 6 months ago. Updated 6 months ago.

Status:ClosedStart date:
Priority:NormalDue date:
Assignee:Go MAEDA% Done:

0%

Category:Issues
Target version:3.4.6
Resolution:Fixed Affected version:

Description

When copying the parent issue having child issue, some issues could not be copied.
The "Copy subtasks" checkbox is checked.

After checking the log, it turned out that only the issue for which the member of the lock account is set to the watcher has not been copied.
Even if the members of the lock account are set on the watcher, I want you to be able to copy the issue.

Redmine 3.4.2
rudy version:2.3.3-p222
Rails version:4.2.8

I will post it for the first time. I'm sorry if I made a mistake in my way.

0001-do-not-propose-locked-watchers-when-copying-an-issue.patch Magnifier (2.34 KB) Marius BALTEANU, 2018-05-14 23:28

0001-unit-test-for-locked-watchers.patch Magnifier (1.19 KB) Marius BALTEANU, 2018-05-15 09:03

0001-unit-test-for-locked-watchers_corrected.patch Magnifier - Patch with typo corrected (1.19 KB) Andreas Deininger, 2018-05-15 14:39


Related issues

Related to Redmine - Defect #27863: If version is closed or locked subtasks don't get copied Closed

Associated revisions

Revision 17342
Added by Go MAEDA 6 months ago

Fix: Copying an issue fails if the issue is watched by a locked user (#28765).

Patch by Marius BALTEANU.

Revision 17343
Added by Go MAEDA 6 months ago

Merged r17342 from trunk to 3.4-stable (#28765).

History

#1 Updated by Go MAEDA 6 months ago

  • Tracker changed from Feature to Defect
  • Subject changed from Issue copy can not be done if lock account member is set on watcher to Copying an issue fails if the issue is watched by a locked user
  • Category set to Issues

I confirmed the problem. Copying an issue fails if the issue is watched by a locked user and a validation error "Watchers is invalid" is displayed.

I will post it for the first time. I'm sorry if I made a mistake in my way.

There was no problem at all. Thank you for reporting this issue.

#2 Updated by Go MAEDA 6 months ago

  • Status changed from New to Confirmed

#3 Updated by Go MAEDA 6 months ago

  • Related to Defect #27863: If version is closed or locked subtasks don't get copied added

#4 Updated by Marius BALTEANU 6 months ago

Attached is a patch with a test included that fixes this issue. I chose to propose in the UI only active users as watchers when copying an issue.

#5 Updated by Go MAEDA 6 months ago

  • Assignee set to Marius BALTEANU

Thank you for working on this issue, Marius. I confirmed that the patch fixes the problem.

But I noticed that inactive users should be excluded not only in the UI but also in Issue#copy_from method because there still be a problem even after applying the patch. Issues which have locked watchers are not copied when admins use project copy feature.

What do you think including the following code in your patch?

Index: app/models/issue.rb
===================================================================
--- app/models/issue.rb    (revision 17329)
+++ app/models/issue.rb    (working copy)
@@ -274,7 +274,8 @@
       end
     end
     unless options[:watchers] == false
-      self.watcher_user_ids = issue.watcher_user_ids.dup
+      self.watcher_user_ids =
+        issue.watcher_users.select{|u| u.status == User::STATUS_ACTIVE}.map(&:id)
     end
     @copied_from = issue
     @copy_options = options

#6 Updated by Marius BALTEANU 6 months ago

Oh, I didn't think to this case, thanks for finding it.

It looks good and I made a unit test also for this scenario (attached).

#7 Updated by Go MAEDA 6 months ago

  • Assignee deleted (Go MAEDA)
  • Target version changed from Candidate for next minor release to 3.4.6

Marius BALTEANU wrote:

It looks good and I made a unit test also for this scenario (attached).

Great, the patch looks perfect now. I am setting target version to 3.4.6. The patches to be committed are as follows:

#8 Updated by Andreas Deininger 6 months ago

In the unit test patch, the name of the test method is misspelled. This typo is fixed in the attached patch.

#9 Updated by Go MAEDA 6 months ago

Andreas Deininger wrote:

In the unit test patch, the name of the test method is misspelled. This typo is fixed in the attached patch.

Thank you for pointing out that "shoud" should be "should".

#10 Updated by Go MAEDA 6 months ago

  • Status changed from Confirmed to Resolved
  • Assignee set to Go MAEDA
  • Resolution set to Fixed

#11 Updated by Go MAEDA 6 months ago

  • Status changed from Resolved to Closed

Committed to the trunk and 3.4-stable branch. Thank you all for reporting and fixing this issue.

Also available in: Atom PDF