]> source.dussan.org Git - redmine.git/commitdiff
Merged r21614 to 5.0-stable (#37135).
authorMarius Balteanu <marius.balteanu@zitec.com>
Sat, 28 May 2022 18:29:24 +0000 (18:29 +0000)
committerMarius Balteanu <marius.balteanu@zitec.com>
Sat, 28 May 2022 18:29:24 +0000 (18:29 +0000)
git-svn-id: https://svn.redmine.org/redmine/branches/5.0-stable@21622 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/models/project_query.rb

index 002437aebfd26414d3c825c0fd2bb0852f0bacac..8c6643c7bb79fd9af58025bd5aa446e7f6f7410c 100644 (file)
@@ -39,10 +39,13 @@ class ProjectQuery < Query
 
   def self.default(project: nil, user: User.current)
     query = nil
-    if user&.logged?
-      query = find_by_id user.pref.default_project_query
+    if user&.logged? && (query_id = user.pref.default_project_query).present?
+      query = find_by(id: query_id)
     end
-    query || find_by_id(Setting.default_project_query)
+    if query.nil? && (query_id = Setting.default_project_query).present?
+      query = find_by(id: query_id)
+    end
+    query
   end
 
   def initialize(attributes=nil, *args)