From 72e2efdc6070bc4aef66042b471a5b20c8daa43b Mon Sep 17 00:00:00 2001 From: Go MAEDA Date: Sun, 31 Jul 2022 13:33:27 +0000 Subject: Default query should not be applied if the query is not allowed to be set as the default (#37499). Patch by Mizuki ISHIKAWA. git-svn-id: https://svn.redmine.org/redmine/trunk@21748 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/models/project_query.rb | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'app/models/project_query.rb') diff --git a/app/models/project_query.rb b/app/models/project_query.rb index 57d0330d1..69d10aeb4 100644 --- a/app/models/project_query.rb +++ b/app/models/project_query.rb @@ -40,14 +40,15 @@ class ProjectQuery < Query ] def self.default(project: nil, user: User.current) - query = nil if user&.logged? && (query_id = user.pref.default_project_query).present? query = find_by(id: query_id) + return query if query&.visible? end - if query.nil? && (query_id = Setting.default_project_query).present? + if (query_id = Setting.default_project_query).present? query = find_by(id: query_id) + return query if query&.visibility == VISIBILITY_PUBLIC end - query + nil end def initialize(attributes=nil, *args) -- cgit v1.2.3