mirror of
https://framagit.org/hubzilla/core.git
synced 2026-06-21 00:52:33 -04:00
Fix default timeouts for z_(fetch|post)_url.
When fetching the default timouts from config, the result is converted to an int via `intval()`, the result of that again is compared strictly to `false`. Since 0 !== false, the default values will never be used, and 0 (no timeout) is passed to curl. This cause requests to hang indefinitely (or until they are killed) when receiving actions that require a lookup or fetch to another site as part of the request processing. (E.g webfinger, or fetching objects that we received an announce action for.) This again cause the request never to return a useful status to the site sending the action, and could cause them to think the Hubzilla site is dead. This patch fixes this by comparing the fetched value from config to 0 instead of false, making the defaults work again if the config is not set (or set to 0).
This commit is contained in:
@@ -116,7 +116,7 @@ function z_fetch_url($url, $binary = false, $redirects = 0, $opts = array()) {
|
||||
}
|
||||
else {
|
||||
$curl_time = intval(@Config::Get('system','curl_timeout'));
|
||||
@curl_setopt($ch, CURLOPT_TIMEOUT, (($curl_time !== false) ? $curl_time : 60));
|
||||
@curl_setopt($ch, CURLOPT_TIMEOUT, (($curl_time !== 0) ? $curl_time : 60));
|
||||
}
|
||||
|
||||
if(x($opts,'connecttimeout') && intval($opts['connecttimeout'])) {
|
||||
@@ -124,7 +124,7 @@ function z_fetch_url($url, $binary = false, $redirects = 0, $opts = array()) {
|
||||
}
|
||||
else {
|
||||
$curl_contime = intval(@Config::Get('system','curl_connecttimeout'));
|
||||
@curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, (($curl_contime !== false) ? $curl_contime : 30));
|
||||
@curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, (($curl_contime !== 0) ? $curl_contime : 30));
|
||||
}
|
||||
|
||||
if(x($opts,'http_auth')) {
|
||||
@@ -298,7 +298,7 @@ function z_post_url($url, $params, $redirects = 0, $opts = array()) {
|
||||
}
|
||||
else {
|
||||
$curl_time = intval(@Config::Get('system','curl_timeout'));
|
||||
@curl_setopt($ch, CURLOPT_TIMEOUT, (($curl_time !== false) ? $curl_time : 60));
|
||||
@curl_setopt($ch, CURLOPT_TIMEOUT, (($curl_time !== 0) ? $curl_time : 60));
|
||||
}
|
||||
|
||||
if(x($opts,'http_auth')) {
|
||||
|
||||
Reference in New Issue
Block a user