Dup attributes instead of issue object.

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@8344 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang 2011-12-24 09:51:26 +00:00
parent bc7ed1e156
commit 8f23043851
1 changed files with 4 additions and 5 deletions

View File

@ -397,8 +397,7 @@ class Issue < ActiveRecord::Base
def init_journal(user, notes = "") def init_journal(user, notes = "")
@current_journal ||= Journal.new(:journalized => self, :user => user, :notes => notes) @current_journal ||= Journal.new(:journalized => self, :user => user, :notes => notes)
@issue_before_change = self.clone @attributes_before_change = attributes.dup
@issue_before_change.status = self.status
@custom_values_before_change = {} @custom_values_before_change = {}
self.custom_values.each {|c| @custom_values_before_change.store c.custom_field_id, c.value } self.custom_values.each {|c| @custom_values_before_change.store c.custom_field_id, c.value }
# Make sure updated_on is updated when adding a note. # Make sure updated_on is updated when adding a note.
@ -927,13 +926,13 @@ class Issue < ActiveRecord::Base
if @current_journal if @current_journal
# attributes changes # attributes changes
(Issue.column_names - %w(id root_id lft rgt lock_version created_on updated_on)).each {|c| (Issue.column_names - %w(id root_id lft rgt lock_version created_on updated_on)).each {|c|
before = @issue_before_change.send(c) before = @attributes_before_change[c]
after = send(c) after = send(c)
next if before == after || (before.blank? && after.blank?) next if before == after || (before.blank? && after.blank?)
@current_journal.details << JournalDetail.new(:property => 'attr', @current_journal.details << JournalDetail.new(:property => 'attr',
:prop_key => c, :prop_key => c,
:old_value => @issue_before_change.send(c), :old_value => before,
:value => send(c)) :value => after)
} }
# custom fields changes # custom fields changes
custom_values.each {|c| custom_values.each {|c|