From 2ea9951175ae38042fa2af4860d111e9e4d1ac5d Mon Sep 17 00:00:00 2001 From: shuaib-swzd <166814920+shuaib-swzd@users.noreply.github.com> Date: Thu, 5 Dec 2024 20:17:44 +0530 Subject: [PATCH] DEV: Safe navigation to handle to nil current_user class issue (#344) Another private plugin is extending this plugin and the current_user check here is a problem -- adding safe navigation does not break any existing functionality but allows for future changes. --- app/controllers/discourse_data_explorer/query_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/discourse_data_explorer/query_controller.rb b/app/controllers/discourse_data_explorer/query_controller.rb index 6b6ecac..2438a7a 100644 --- a/app/controllers/discourse_data_explorer/query_controller.rb +++ b/app/controllers/discourse_data_explorer/query_controller.rb @@ -147,7 +147,7 @@ module ::DiscourseDataExplorer query_params = {} query_params = MultiJson.load(params[:params]) if params[:params] - opts = { current_user: current_user.username } + opts = { current_user: current_user&.username } opts[:explain] = true if params[:explain] == "true" opts[:limit] = if params[:format] == "csv"