-
Notifications
You must be signed in to change notification settings - Fork 837
Description
Edit: I see issue #3942 already appears to cover this. My apologies for not having searched beforehand.
Affected page
https://php.net/function.curl-errno, https://php.net/function.curl-error
Current issue
When executing an individual CurlHandle using curl_exec(), you can then retrieve potential errors and error codes using curl_errno() or curl_error().
When a CurlHandle is executed via a CurlMultiHandle using curl_multi_exec(), these methods will simply return 0 or "" respectively, as if no error had occured.
This behaviour is not documented anywhere, neither on the page for curl_errno(), nor for curl_error(), nor for curl_multi_info_read().
Suggested improvement
The pages should feature a clearly visible, visually distinct notice that mentions this behaviour. Another user has previously mentioned this in a comment 16 years ago, however this hint is currently buried beyond a list of error constants in the topmost comment. I believe it should be part of the documentation.
Alternatively, this could also be considered a bug, however, it would still need to be documented for past versions regardless.
Additional context (optional)
Individual CurlHandle execution:
$curlHandle = curl_init("thishostdoesnotresolve"); // Invalid host, will cause error number 6
curl_exec($curlHandle);
// Outputs "6"
echo curl_errno($curlHandle);Executing a CurlHandle via CurlMultiHandle:
$curlHandle = curl_init("thishostdoesnotresolve"); // Invalid host, will cause error number 6
$multiHandle = curl_multi_init();
curl_multi_add_handle($multiHandle, $curlHandle);
do {
curl_multi_exec($multiHandle, $stillRunning);
} while ($stillRunning);
// The assumed behaviour is that the individual handles know their own errors,
// therefore, curl_errno() applied to an executed handle would return its error, if any.
// However, this outputs "0"
echo curl_errno($curlHandle);
// This is the only way to retrieve curl errors while using a CurlMultiHandle
// [result] => 6
print_r(curl_multi_info_read($multi));