Skip to content

Commit

Permalink
dev/core#1035 Add in new setting http_timeout to set how long in seco…
Browse files Browse the repository at this point in the history
…nds should HTTP requests last for to fix dev/core#1035

Handle situations where a 0 timeout is passed in
  • Loading branch information
seamuslee001 committed Jun 14, 2019
1 parent eff849b commit 4ccb0a2
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CRM/Admin/Form/Setting/Miscellaneous.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -79,6 +80,7 @@ public function preProcess() {
'recentItemsProviders',
'dedupe_default_limit',
'prevNextBackend',
'http_timeout',
]);
}

Expand Down
8 changes: 6 additions & 2 deletions CRM/Utils/Check/Component.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
19 changes: 19 additions & 0 deletions settings/Core.setting.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
],
];

0 comments on commit 4ccb0a2

Please sign in to comment.