php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #79318 curl_errno() is always 0 if there was an error while used with curl_multi()
Submitted: 2020-02-28 21:15 UTC Modified: -
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: work at christoph-kluge dot eu Assigned:
Status: Open Package: cURL related
PHP Version: 7.3.15 OS:
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: work at christoph-kluge dot eu
New email:
PHP Version: OS:

 

 [2020-02-28 21:15 UTC] work at christoph-kluge dot eu
Description:
------------
I was wondering why curl_errno() returned a 0 while beeing using with a curl_multi_init(). Not sure if this is a bug or if it's a documentation issue so I stated it first as an documentation issue.

It seems that the error is not populated into the resource. Only when I call curl_multi_info_read() then it gets populated into the resource.

References:

* https://bugs.php.net/bug.php?id=60660
* https://bugs.php.net/bug.php?id=33570
* https://bugs.php.net/bug.php?id=48304

Test script:
---------------
$handles = [];
$urls = [
    'https://www.google.com?v1',
    'https://wwwgooglecom?v2',
    'https://www.google.com?v3',
];

$mh = curl_multi_init();
foreach ($urls as $key => $value) {
    $handles[$key] = curl_init($value);
    curl_setopt($handles[$key], CURLOPT_HEADER, true);
    curl_setopt($handles[$key], CURLOPT_TIMEOUT, 10);
    curl_setopt($handles[$key], CURLOPT_RETURNTRANSFER, true);
    curl_multi_add_handle($mh, $handles[$key]);
}

do {
    $status = curl_multi_exec($mh, $running);
    curl_multi_select($mh);
} while ($running > 0 && $status === CURLM_OK);

// while ($result = curl_multi_info_read($mh)) {} // <<< uncomment this will give you the expected result

foreach($handles as $ch) {
    echo "Handle: " . curl_errno($ch) . PHP_EOL;
}

Expected result:
----------------
$ php test.php 
Result: (0) 
Result: (6) Could not resolve: wwwgooglecom (Domain name not found)
Result: (0) 


Actual result:
--------------
$ php test.php 
Result: (0) 
Result: (0) 
Result: (0)

Patches

Pull Requests

 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Nov 21 15:01:30 2024 UTC