From 94cd5ac0b1b654ba55028c3cdead1bfb40af2991 Mon Sep 17 00:00:00 2001 From: Sam <sam.saffron@gmail.com> Date: Mon, 9 Nov 2020 16:46:52 +1100 Subject: [PATCH] FIX: global setting needs to be coerced to float (#11162) disable_search_queue_threshold needs to be coerced to a float so it is not treated as a string when sub second values are provided. Longer term fix is to possibly provide hints in the config so we do the coersion automatically. However this would be a far more complex change. --- app/controllers/search_controller.rb | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/app/controllers/search_controller.rb b/app/controllers/search_controller.rb index c909fc09145..be26e2724bb 100644 --- a/app/controllers/search_controller.rb +++ b/app/controllers/search_controller.rb @@ -173,9 +173,13 @@ class SearchController < ApplicationController protected def site_overloaded? - (queue_time = request.env['REQUEST_QUEUE_SECONDS']) && - (GlobalSetting.disable_search_queue_threshold > 0) && - (queue_time > GlobalSetting.disable_search_queue_threshold) + queue_time = request.env['REQUEST_QUEUE_SECONDS'] + if queue_time + threshold = GlobalSetting.disable_search_queue_threshold.to_f + threshold > 0 && queue_time > threshold + else + false + end end def rate_limit_search