]> source.dussan.org Git - redmine.git/commitdiff
Reduce an extra SQL query in IssuesController#retrieve_default_query (#40775).
authorGo MAEDA <maeda@farend.jp>
Tue, 4 Jun 2024 09:37:34 +0000 (09:37 +0000)
committerGo MAEDA <maeda@farend.jp>
Tue, 4 Jun 2024 09:37:34 +0000 (09:37 +0000)
Patch by Go MAEDA (@maeda).

git-svn-id: https://svn.redmine.org/redmine/trunk@22854 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/controllers/issues_controller.rb

index 76e7ed921cfd0693085a545ee0502bff2a6d98a6..8528a2fcace5f6a13873348d05e5032d1a8025b6 100644 (file)
@@ -502,8 +502,9 @@ class IssuesController < ApplicationController
       return
     end
     if !params[:set_filter] && use_session && session[:issue_query]
+      # Don't apply the default query if a valid query id is set in the session
       query_id, project_id = session[:issue_query].values_at(:id, :project_id)
-      return if IssueQuery.where(id: query_id).exists? && project_id == @project&.id
+      return if query_id && project_id == @project&.id && IssueQuery.exists?(id: query_id)
     end
     if default_query = IssueQuery.default(project: @project)
       params[:query_id] = default_query.id