From 29a5befad88db0bee794af282d71edf2a0a4966c Mon Sep 17 00:00:00 2001 From: William Desportes Date: Fri, 20 Mar 2026 18:36:32 +0100 Subject: [PATCH] Fix getURLContent should serialize arguments and allow array for CURLOPT_POSTFIELDS (#37560) ``` PHP Warning: Array to string conversion in htdocs/core/lib/geturl.lib.php on line 52 ``` Backport of ec2f4146c35e2e24b6e4c5cf7aaddc2e67b43ecc --- htdocs/core/lib/geturl.lib.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/htdocs/core/lib/geturl.lib.php b/htdocs/core/lib/geturl.lib.php index 3398189a771..9d91365a738 100644 --- a/htdocs/core/lib/geturl.lib.php +++ b/htdocs/core/lib/geturl.lib.php @@ -28,13 +28,13 @@ * - you can set MAIN_SECURITY_ANTI_SSRF_SERVER_IP to set static ip of server * - common local lookup ips like 127.*.*.* are automatically added * - * @param string $url URL to call. - * @param string $postorget 'POST', 'GET', 'HEAD', 'PUT', 'PUTALREADYFORMATED', 'POSTALREADYFORMATED', 'DELETE' - * @param string $param Parameters of URL (x=value1&y=value2) or may be a formated content with $postorget='PUTALREADYFORMATED' - * @param integer $followlocation 0=Do not follow, 1=Follow location. - * @param string[] $addheaders Array of string to add into header. Example: ('Accept: application/xrds+xml', ....) - * @param string[] $allowedschemes List of schemes that are allowed ('http' + 'https' only by default) - * @param int $localurl 0=Only external URL are possible, 1=Only local URL, 2=Both external and local URL are allowed. + * @param string $url URL to call. + * @param string $postorget 'POST', 'GET', 'HEAD', 'PUT', 'PUTALREADYFORMATED', 'POSTALREADYFORMATED', 'DELETE' + * @param string|array $param Parameters of URL (x=value1&y=value2) or may be a formated content with $postorget='PUTALREADYFORMATED' + * @param integer $followlocation 0=Do not follow, 1=Follow location. + * @param string[] $addheaders Array of string to add into header. Example: ('Accept: application/xrds+xml', ....) + * @param string[] $allowedschemes List of schemes that are allowed ('http' + 'https' only by default) + * @param int $localurl 0=Only external URL are possible, 1=Only local URL, 2=Both external and local URL are allowed. * @return array Returns an associative array containing the response from the server array('content'=>response, 'curl_error_no'=>errno, 'curl_error_msg'=>errmsg...) */ function getURLContent($url, $postorget = 'GET', $param = '', $followlocation = 1, $addheaders = array(), $allowedschemes = array('http', 'https'), $localurl = 0) @@ -47,7 +47,7 @@ function getURLContent($url, $postorget = 'GET', $param = '', $followlocation = $PROXY_USER = empty($conf->global->MAIN_PROXY_USER) ? 0 : $conf->global->MAIN_PROXY_USER; $PROXY_PASS = empty($conf->global->MAIN_PROXY_PASS) ? 0 : $conf->global->MAIN_PROXY_PASS; - dol_syslog("getURLContent postorget=".$postorget." URL=".$url." param=".$param); + dol_syslog("getURLContent postorget=".$postorget." URL=".$url." json_encode(param)=".json_encode($param)); //setting the curl parameters. $ch = curl_init();