Bug #79176 [Com]: Since 7 years this function randomly fails when using microtime input
| From: | a at b dot c dot de | Date: | Tue, 28 Jan 2020 03:12:53 +0000 |
| Subject: | Bug #79176 [Com]: Since 7 years this function randomly fails when using microtime input | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-225180@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=79176&edit=1
ID: 79176
Comment by: a at b dot c dot de
Reported by: h dot kocznar at compunect dot com
Summary: Since 7 years this function randomly fails when
using microtime input
Status: Not a bug
Type: Bug
Package: Date/time related
Operating System: All
PHP Version: 7.4.2
Assigned To: cmb
Block user comment: N
Private report: N
New Comment:
> we have millions of php scripts that randomly fail.
[citation needed]
Previous Comments:
------------------------------------------------------------------------
[2020-01-27 23:51:55] h dot kocznar at compunect dot com
I understand how it happens, I agree that it's a not too great situation as the input expected
is having a "." and microtime() returns it without sometimes.
In theory you are right, the function does what it is supposed to do.
But in the real world we have millions of php scripts that randomly fail.
Tt's probably often critical logging functions (as in my case).
Solution:
Just make microtime() always return a dot.
If the value is an exact integer you can just add 0.00001 to it.
It won't make any difference anywhere (the function isn't that precise anyway).
It's a workaround but it's one for the better of PHP, no one will ever notice it except
that millions of errors suddenly go away.
------------------------------------------------------------------------
[2020-01-27 23:09:46] requinix@php.net
You can't rely on the *float* being returned by microtime() to be compatible with the *string*
input expected by createFromFormat. This is one of those times that loose typing is a disadvantage:
in a strictly-typed language, this wouldn't compile.
Protip: sprintf() is good at converting numbers to strings.
------------------------------------------------------------------------
[2020-01-27 23:01:16] h dot kocznar at compunect dot com
Of course this is a bug in PHP..
I am irritated that such a obvious bug can be ignored, is there no quality control path that makes
sure such mistakes are avoided ?
------------------------------------------------------------------------
[2020-01-27 22:34:07] cmb@php.net
Sorry, but your problem does not imply a bug in PHP itself. For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system
is not the
appropriate forum for asking support questions. Due to the volume
of reports we can not explain in detail here why your report is not
a bug. The support channels will be able to provide an explanation
for you.
Thank you for your interest in PHP.
------------------------------------------------------------------------
[2020-01-27 17:44:40] h dot kocznar at compunect dot com
Wrongly closed bug report: https://bugs.php.net/bug.php?id=64414
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
https://bugs.php.net/bug.php?id=79176
--
Edit this bug report at https://bugs.php.net/bug.php?id=79176&edit=1