Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dev/core#1035 Add in new setting http_timeout to set how long in seco… #14525

Merged
merged 1 commit into from
Jun 15, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions CRM/Utils/Check/Component.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
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.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'),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a bit torn about mentioning guzzle here rather than being more generic - but it could iterate I guess

'help_text' => ts('Set the number of seconds http requests should run for before terminating'),
],
];