mirror of
https://github.com/redmine/redmine.git
synced 2025-11-05 04:45:57 +01:00
Fixes #820: invalid project id causes a NoMethodError in SearchController (Angel Dobbs-Sciortino).
git-svn-id: http://redmine.rubyforge.org/svn/trunk@1237 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
@@ -17,6 +17,8 @@
|
||||
|
||||
class SearchController < ApplicationController
|
||||
layout 'base'
|
||||
|
||||
before_filter :find_optional_project
|
||||
|
||||
helper :messages
|
||||
include MessagesHelper
|
||||
@@ -36,11 +38,6 @@ class SearchController < ApplicationController
|
||||
return
|
||||
end
|
||||
|
||||
if params[:id]
|
||||
find_project
|
||||
return unless check_project_privacy
|
||||
end
|
||||
|
||||
if @project
|
||||
# only show what the user is allowed to view
|
||||
@object_types = %w(issues news documents changesets wiki_pages messages)
|
||||
@@ -104,8 +101,10 @@ class SearchController < ApplicationController
|
||||
end
|
||||
|
||||
private
|
||||
def find_project
|
||||
def find_optional_project
|
||||
return true unless params[:id]
|
||||
@project = Project.find(params[:id])
|
||||
check_project_privacy
|
||||
rescue ActiveRecord::RecordNotFound
|
||||
render_404
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user