-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Add notification about DateTime and microseconds support #2186
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
Conversation
The addition of microseconds to DateTime are great; but looking at https://3v4l.org/bughunt/ I see hundreds of scripts unexpectedly 'failing' because two variables are no longer equal due to microsecond differences (eg. https://3v4l.org/7rdeS ). Hopefully this notice will prevent some bogus bugreports
I commented on this issue below the commit here, noone seems to care unfortunately. I'm going to properly report it as a bug (BC break) in RC. |
I agree, see my related comment @ https://bugs.php.net/bug.php?id=73301. This change should have been added to 7.1.0 from the start; or moved to 7.2. It seems some PHP developers handle a different definition then what is generally accepted:
I find it intriguing this specific change was added by @derickr who is normally very vocal against any change that creates BC behaviour (see various RFC votes) |
Hmm, nice catch with setTime BC break, it definitely breaks subclasses (and is not even documented). 😟 |
I asked @dshafik before merging this large amount if bug fixes. |
@@ -280,6 +280,9 @@ PHP 7.1 UPGRADE NOTES | |||
. Timezone initialization failure from serialized data will now throw an | |||
instance of Error from __wakeup() or __set_state() instead of resulting in | |||
a fatal error. | |||
. DateTime instances now support microseconds. Please note this can have impact | |||
when comparing; eg. this would previously return TRUE, but now returns FALSE: | |||
(new DateTime('first day of next month') == new DateTime('first day of next month')); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not a new change. This could result in false before if the first and second instantiation spanned a change in current second.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
True, but if generating a DateTime takes roughly 4 μs (which it does for me), this happens ~ 250.000 times more often
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
True, but if generating a DateTime takes roughly 4 μs (which it does for me), this happens ~ 250.000 times more often
That doesn't make that the developer's original assumption was correct. There was still a bug in their code.
People not understanding an issue should not prevent fixing bugs. It's in the same league as not knowing about DST and assuming that each day is 86400 seconds long.
I will add something to UPGRADING, but with a better wording, so will be closing this PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is definitely a gotcha for faulty code that happened to work most of the times. The good thing is the bug will surface more often and get fixed!
Note in UPGRADING for 7.1 has been added with 69a3659
Isn't there really? How about these?
Don't they look like a BC break? They do, at least to me. The behavior obviously changed.
That is perfectly ok if they break BC, some of them actually look rather like feature requests...
Not if they break BC with stable versions. This makes any semver promises/expectations void. |
|
I concur with @arjenschol here, particularly on the BC breaks.
|
Defaulting microseconds to zero, like seconds, should avoid this BC break and avoid the need for new classes and methods. But keep in mind, the final release of 7.1 is due in a few weeks and if this can't be fixed quickly, it should be reverted so that it doesn't be delayed 7.1 |
@@ -280,6 +280,9 @@ PHP 7.1 UPGRADE NOTES | |||
. Timezone initialization failure from serialized data will now throw an | |||
instance of Error from __wakeup() or __set_state() instead of resulting in | |||
a fatal error. | |||
. DateTime instances now support microseconds. Please note this can have impact | |||
when comparing; eg. this would previously return TRUE, but now returns FALSE: | |||
(new DateTime('first day of next month') == new DateTime('first day of next month')); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
True, but if generating a DateTime takes roughly 4 μs (which it does for me), this happens ~ 250.000 times more often
That doesn't make that the developer's original assumption was correct. There was still a bug in their code.
People not understanding an issue should not prevent fixing bugs. It's in the same league as not knowing about DST and assuming that each day is 86400 seconds long.
I will add something to UPGRADING, but with a better wording, so will be closing this PR.
7.1.0RC6 is being built tomorrow or the next day, as the last RC, I'd like to see this resolved before then or we will have to revert. True bug fixes can be done in 7.1.1 and beyond. |
This pull request is unrelated to that dicussion. |
FWIW; 69a3659 |
The addition of microseconds to DateTime are great; but looking at the 3v4l.org bughunt output I see hundreds of scripts unexpectedly 'failing' because two variables are no longer equal due to non-obvious microsecond differences (eg. https://3v4l.org/7rdeS ).
Hopefully this notice will prevent some bogus bugreports