Browse Source

Preload project when possible (#5754).

git-svn-id: http://svn.redmine.org/redmine/trunk@15314 e93f8b46-1217-0410-a6f0-8f06a7374b81
tags/3.3.0
Jean-Philippe Lang 8 years ago
parent
commit
933dc946d4
1 changed files with 6 additions and 1 deletions
  1. 6
    1
      app/controllers/watchers_controller.rb

+ 6
- 1
app/controllers/watchers_controller.rb View File

@@ -131,7 +131,12 @@ class WatchersController < ApplicationController
klass = Object.const_get(params[:object_type].camelcase) rescue nil
return unless klass && klass.respond_to?('watched_by')

objects = klass.where(:id => Array.wrap(params[:object_id])).to_a
scope = klass.where(:id => Array.wrap(params[:object_id]))
if klass.reflect_on_association(:project)
scope = scope.preload(:project => :enabled_modules)
end
objects = scope.to_a

raise Unauthorized if objects.any? do |w|
if w.respond_to?(:visible?)
!w.visible?

Loading…
Cancel
Save