Doc #79318 [NEW]: curl_errno() is always 0 if there was an error while used with curl_multi()

From: Date: Fri, 28 Feb 2020 21:15:04 +0000
Subject: Doc #79318 [NEW]: curl_errno() is always 0 if there was an error while used with curl_multi()
Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-17343@lists.php.net to get a copy of this message
From:             work at christoph-kluge dot eu
Operating system: 
PHP version:      7.3.15
Package:          cURL related
Bug Type:         Documentation Problem
Bug description:curl_errno() is always 0 if there was an error while used with curl_multi()

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)

-- 
Edit bug report at https://bugs.php.net/bug.php?id=79318&edit=1
-- 
Fix committed:                    https://bugs.php.net/fix.php?id=79318&r=fixed
Fixed in release:                 https://bugs.php.net/fix.php?id=79318&r=alreadyfixed
Need backtrace:                   https://bugs.php.net/fix.php?id=79318&r=needtrace
Need Reproduce Script:            https://bugs.php.net/fix.php?id=79318&r=needscript
Try newer version:                https://bugs.php.net/fix.php?id=79318&r=oldversion
Not developer issue:              https://bugs.php.net/fix.php?id=79318&r=support
Expected behavior:                https://bugs.php.net/fix.php?id=79318&r=notwrong
Not enough info:                  https://bugs.php.net/fix.php?id=79318&r=notenoughinfo
Submitted twice:                  https://bugs.php.net/fix.php?id=79318&r=submittedtwice
register_globals:                 https://bugs.php.net/fix.php?id=79318&r=globals
PHP version support discontinued: https://bugs.php.net/fix.php?id=79318&r=phptooold
Daylight Savings:                 https://bugs.php.net/fix.php?id=79318&r=dst
IIS Stability:                    https://bugs.php.net/fix.php?id=79318&r=isapi
Install GNU Sed:                  https://bugs.php.net/fix.php?id=79318&r=gnused
Floating point limitations:       https://bugs.php.net/fix.php?id=79318&r=float
No Zend Extensions:               https://bugs.php.net/fix.php?id=79318&r=nozend
MySQL Configuration Error:        https://bugs.php.net/fix.php?id=79318&r=mysqlcfg


Thread (2 messages)

« previous php.doc.bugs (#17343) next »