Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PHP 7.3: use hrtime() instead of microtime() #2214

Closed
Llbe opened this issue Nov 21, 2018 · 2 comments · Fixed by #2242
Closed

PHP 7.3: use hrtime() instead of microtime() #2214

Llbe opened this issue Nov 21, 2018 · 2 comments · Fixed by #2242
Assignees

Comments

@Llbe
Copy link

Llbe commented Nov 21, 2018

Guzzle version(s) affected: 6.3.3

Description
Consider switching from microtime() to hrtime(), available in PHP 7.3. It provides a monotonic timestamp rather than a realtime timestamp.

How to reproduce
Using microtime() is unsafe e.g. on a DST crossover or whenever the system time is adjusted, since the timestamps aren't relative to each other.

It is used in the CurlMultiHandler and the on_stats option.

Apart from needing to keep support for < 7.3, the change here should be without a BC break.

@Llbe Llbe changed the title PHP 7.3: use hrtime() in favor of microtime() PHP 7.3: use hrtime() instead of microtime() Nov 21, 2018
@Llbe
Copy link
Author

Llbe commented Nov 21, 2018

Basically function_exists('hrtime') ? hrtime(true) / 1e9 : microtime(true) could be used (an internal wrapper would be preferable of course). See https://3v4l.org/BATQ7

@Dzhuneyt
Copy link
Contributor

Dzhuneyt commented Jan 4, 2019

Fixed in #2242

@sagikazarmark sagikazarmark self-assigned this Jan 6, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants