Use scoped method instead of merge_conditions.

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@8290 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang 2011-12-18 15:02:46 +00:00
parent e75549cc8e
commit b8ce888d98

View File

@ -869,12 +869,12 @@ class Issue < ActiveRecord::Base
def self.update_versions(conditions=nil) def self.update_versions(conditions=nil)
# Only need to update issues with a fixed_version from # Only need to update issues with a fixed_version from
# a different project and that is not systemwide shared # a different project and that is not systemwide shared
Issue.all(:conditions => merge_conditions("#{Issue.table_name}.fixed_version_id IS NOT NULL" + Issue.scoped(:conditions => conditions).all(
" AND #{Issue.table_name}.project_id <> #{Version.table_name}.project_id" + :conditions => "#{Issue.table_name}.fixed_version_id IS NOT NULL" +
" AND #{Version.table_name}.sharing <> 'system'", " AND #{Issue.table_name}.project_id <> #{Version.table_name}.project_id" +
conditions), " AND #{Version.table_name}.sharing <> 'system'",
:include => [:project, :fixed_version] :include => [:project, :fixed_version]
).each do |issue| ).each do |issue|
next if issue.project.nil? || issue.fixed_version.nil? next if issue.project.nil? || issue.fixed_version.nil?
unless issue.project.shared_versions.include?(issue.fixed_version) unless issue.project.shared_versions.include?(issue.fixed_version)
issue.init_journal(User.current) issue.init_journal(User.current)