diff --git a/CRM/Admin/Form/Setting/Miscellaneous.php b/CRM/Admin/Form/Setting/Miscellaneous.php index 8b92a4b411f5..0e004d1e94a5 100644 --- a/CRM/Admin/Form/Setting/Miscellaneous.php +++ b/CRM/Admin/Form/Setting/Miscellaneous.php @@ -57,6 +57,7 @@ class CRM_Admin_Form_Setting_Miscellaneous extends CRM_Admin_Form_Setting { 'remote_profile_submissions' => CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'allow_alert_autodismissal' => CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'prevNextBackend' => CRM_Core_BAO_Setting::SEARCH_PREFERENCES_NAME, + 'http_timeout' => CRM_Core_BAO_Setting::SEARCH_PREFERENCES_NAME, ]; public $_uploadMaxSize; @@ -79,6 +80,7 @@ public function preProcess() { 'recentItemsProviders', 'dedupe_default_limit', 'prevNextBackend', + 'http_timeout', ]); } diff --git a/CRM/Utils/Check/Component.php b/CRM/Utils/Check/Component.php index 9b2a02938cf7..55210b7a6c72 100644 --- a/CRM/Utils/Check/Component.php +++ b/CRM/Utils/Check/Component.php @@ -62,11 +62,15 @@ public function checkAll() { * Check if file exists on given URL. * * @param string $url - * @param float $timeout + * @param float|bool $timeout * * @return bool */ - public function fileExists($url, $timeout = 0.50) { + public function fileExists($url, $timeout = FALSE) { + // Timeout past in maybe 0 in which case we should still permit it (0 is infinite). + if (!$timeout && $timeout !== 0) { + $timeout = (float) Civi::settings()->get('http_timeout'); + } $fileExists = FALSE; try { $guzzleClient = new GuzzleHttp\Client(); diff --git a/settings/Core.setting.php b/settings/Core.setting.php index 77dc4cce90ef..6f17d0214f60 100644 --- a/settings/Core.setting.php +++ b/settings/Core.setting.php @@ -1062,4 +1062,23 @@ 'description' => ts('Acceptable Mime Types that can be used as part of file urls'), 'help_text' => NULL, ], + 'http_timeout' => [ + 'group_name' => 'CiviCRM Preferences', + 'group' => 'core', + 'name' => 'http_timeout', + 'type' => 'Integer', + 'quick_form_type' => 'Element', + 'html_type' => 'text', + 'html_attributes' => [ + 'size' => 2, + 'maxlength' => 3, + ], + 'default' => 5, + 'add' => '5.16', + 'title' => ts('HTTP request timeout'), + 'is_domain' => 1, + 'is_contact' => 0, + 'description' => ts('How long should HTTP requests through Guzzle application run for in seconds'), + 'help_text' => ts('Set the number of seconds http requests should run for before terminating'), + ], ];