Project

General

Profile

Actions

Defect #8239

closed

notes field is not propagated during issue copy

Added by Janusz Harkot over 13 years ago. Updated over 13 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Category:
Issues
Target version:
Start date:
2011-04-27
Due date:
% Done:

0%

Estimated time:
Resolution:
Fixed
Affected version:

Description

scenario (vanilla installation of redmine):

- open existing issue
- click copy
- add notes
- click copy button

notes are not visible, they are lost


Files

issue_copy.patch (2.78 KB) issue_copy.patch Etienne Massip, 2011-05-23 19:06

Related issues

Related to Redmine - Defect #6901: Copy/Move an issue does not give any history of who actually did the action.Closed2010-11-15

Actions
Actions #1

Updated by Etienne Massip over 13 years ago

  • Target version set to Candidate for next minor release

Confirmed with demo site, I'll try to investigate further.

Actions #2

Updated by Etienne Massip over 13 years ago

Had a quick look yesterday evening, Issue#new.copy_from does not copy current journal.

Maybe that call to Issue#init_journal in IssueMovesController should be moved to model after call to #copy_from and only for a move action (do we really need a journal entry in a copy context if no notes are filled in) ?

Actions #3

Updated by Etienne Massip over 13 years ago

This change prevents double #save :

Index: app/models/issue.rb
===================================================================
--- app/models/issue.rb    (revision 5543)
+++ app/models/issue.rb    (working copy)
@@ -147,10 +147,18 @@
     end || false
   end

-  def move_to_project_without_transaction(new_project, new_tracker = nil, options = {})
+  def move_to_project_without_transaction(new_project, notes = nil, new_tracker = nil, options = {})
     options ||= {}
-    issue = options[:copy] ? self.class.new.copy_from(self) : self
-    
+
+    if options[:copy]
+      issue = self.class.new.copy_from(self)
+      issue.instance_variable_set :@current_journal, Journal.new(:journalized => issue, :user => User.current, :notes => notes) if notes.present?
+    else
+      issue = self
+      issue.init_journal(User.current)
+      issue.current_journal.notes = notes if notes.present?
+    end
+
     if new_project && issue.project_id != new_project.id
       # delete issue relations
       unless Setting.cross_project_issue_relations?
@@ -867,7 +875,8 @@
                                                       :prop_key => c,
                                                       :old_value => @issue_before_change.send(c),
                                                       :value => send(c)) unless send(c)==@issue_before_change.send(c)
-      }
+      } if @issue_before_change
+
       # custom fields changes
       custom_values.each {|c|
         next if (@custom_values_before_change[c.custom_field_id]==c.value ||
@@ -876,7 +885,8 @@
                                                       :prop_key => c.custom_field_id,
                                                       :old_value => @custom_values_before_change[c.custom_field_id],
                                                       :value => c.value)
-      }      
+      } if @custom_values_before_change
+
       @current_journal.save
       # reset current journal
       init_journal @current_journal.user, @current_journal.notes
Index: app/controllers/issue_moves_controller.rb
===================================================================
--- app/controllers/issue_moves_controller.rb    (revision 5543)
+++ app/controllers/issue_moves_controller.rb    (working copy)
@@ -17,10 +17,8 @@
       moved_issues = []
       @issues.each do |issue|
         issue.reload
-        issue.init_journal(User.current)
-        issue.current_journal.notes = @notes if @notes.present?
         call_hook(:controller_issues_move_before_save, { :params => params, :issue => issue, :target_project => @target_project, :copy => !!@copy })
-        if r = issue.move_to_project(@target_project, new_tracker, {:copy => @copy, :attributes => extract_changed_attributes_for_move(params)})
+        if r = issue.move_to_project(@target_project, @notes, new_tracker, {:copy => @copy, :attributes => extract_changed_attributes_for_move(params)})
           moved_issues << r
         else
           unsaved_issue_ids << issue.id
Actions #4

Updated by johann sebatian over 13 years ago

  • Assignee set to johann sebatian
Actions #5

Updated by Etienne Massip over 13 years ago

  • Assignee deleted (johann sebatian)
  • Target version changed from Candidate for next minor release to 1.2.0
Actions #6

Updated by Etienne Massip over 13 years ago

Less intrusive based on trunk ?

Actions #7

Updated by Jean-Philippe Lang over 13 years ago

  • Status changed from New to Closed
  • Resolution set to Fixed

This was fixed in r5602. Anything wrong with it?

Actions

Also available in: Atom PDF