php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #77264 curl_getinfo returning microseconds, not seconds
Submitted: 2018-12-07 18:56 UTC Modified: 2018-12-08 21:41 UTC
From: chris at lodesys dot com Assigned: pierrick (profile)
Status: Closed Package: cURL related
PHP Version: 7.3.0 OS: Windows
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: chris at lodesys dot com
New email:
PHP Version: OS:

 

 [2018-12-07 18:56 UTC] chris at lodesys dot com
Description:
------------
Under PHP 7.3.0, cURL appears to be returning times in microseconds instead of seconds.

Running PHP executables downloaded from from http://windows.php.net

The following example is from the curl_getinfo documentation page -- https://secure.php.net/manual/en/function.curl-getinfo.php

Test script:
---------------
<?php
// Create a cURL handle
$ch = curl_init('http://www.example.com/');

// Execute
curl_exec($ch);

// Check if any error occurred
if (!curl_errno($ch)) {
  $info = curl_getinfo($ch);
  echo 'Took ', $info['total_time'], ' seconds to send a request to ', $info['url'], "\n";
}

// Close handle
curl_close($ch);
?>


Expected result:
----------------
The expected result is less than 0.5 seconds "to send a request". 

This is what I'm seeing when running this script with PHP 7.2.12 

Actual result:
--------------
I'm getting values like 110000 seconds "to send a request" (30.5 hours).

Same script run with PHP 7.3.0

Have the same microseconds-not-seconds problem with all the time values

Total_Time
Namelookup_Time
Connect_Time
Pretransfer_Time
Starttransfer_Time


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2018-12-08 10:34 UTC] cmb@php.net
-Status: Open +Status: Verified -Package: HTTP related +Package: cURL related -Assigned To: +Assigned To: pierrick
 [2018-12-08 10:34 UTC] cmb@php.net
If libcurl ≥ 7.61.0 is available, the times are indeed given as
int in microseconds[1]; for older libcurl they are floats in
seconds[2].  Is this intentional, Pierrick?  If so, we have to
prominently document the change in UPGRADING and the migration
guide etc.  However, it might be better to introduce new array
elements (e.g. total_time_us) instead of overwriting the old ones
for BC reasons.

[1] <https://github.com/php/php-src/blob/php-7.3.0/ext/curl/interface.c#L3341-L3343>
[2] <https://github.com/php/php-src/blob/php-7.3.0/ext/curl/interface.c#L3217-L3219>
 [2018-12-08 15:42 UTC] pierrick@php.net
Sorry about this I went to fast. It's my mistake. I'll commit a fix for this soon.
 [2018-12-08 21:41 UTC] pierrick@php.net
-Status: Verified +Status: Closed
 [2018-12-08 21:41 UTC] pierrick@php.net
The fix for this bug has been committed.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.

 For Windows:

http://windows.php.net/snapshots/
 
Thank you for the report, and for helping us make PHP better.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Oct 08 13:01:26 2024 UTC