diff --git a/CRM/Utils/Check/Component.php b/CRM/Utils/Check/Component.php index 9b2a02938cf7..f07f2923fc9a 100644 --- a/CRM/Utils/Check/Component.php +++ b/CRM/Utils/Check/Component.php @@ -62,16 +62,20 @@ public function checkAll() { * Check if file exists on given URL. * * @param string $url - * @param float $timeout + * @param float|bool $timeoutOverride * * @return bool */ - public function fileExists($url, $timeout = 0.50) { + public function fileExists($url, $timeoutOverride = FALSE) { + // Timeout past in maybe 0 in which case we should still permit it (0 is infinite). + if (!$timeoutOverride && $timeoutOverride !== 0) { + $timeoutOverride = (float) Civi::settings()->get('http_timeout'); + } $fileExists = FALSE; try { $guzzleClient = new GuzzleHttp\Client(); $guzzleResponse = $guzzleClient->request('GET', $url, array( - 'timeout' => $timeout, + 'timeout' => $timeoutOverride, )); $fileExists = ($guzzleResponse->getStatusCode() == 200); } diff --git a/settings/Core.setting.php b/settings/Core.setting.php index 77dc4cce90ef..2b8bdf3e04ba 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.15', + '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'), + ], ];