-
Notifications
You must be signed in to change notification settings - Fork 7.8k
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
8.2.9 DateTime:createFromFormat stopped parsing datetime with containing extra space. #11854
Comments
(Note: 8.2.9 GA is planned for tomorrow and has already been tagged.) @derickr Is it intentional that timelib_eat_spaces now only eats a single character? Because before it would eat as many as it could. |
This currently breaks Laravel's Is there any chance for an 8.2.10 to be shipped quickly that fixes this regression? |
I'm not Derick, but I'm pretty confident that it is unintentional that it now stops at consuming a single space. |
…time with containing extra space.
➡️ @saundefined and @adoy |
On 2 August 2023 21:15:50 BST, Damian Wadley ***@***.***> wrote:
> Is there any chance for an 8.2.10 to be shipped quickly that fixes this regression?
➡️ @saundefined and @adoy
I didn't see this until now, although I was online all day. But these fixes need to be done in derickr/timelib.
You'll have to convince the RMs for an early release.
It's also surprising there were no tests for this.
|
|
On 2 August 2023 22:24:25 BST, hidden_nickname ***@***.***> wrote:
@derickr
> But these fixes need to be done in derickr/timelib.
derickr/timelib#148
That's good. For some reason that also didn't produce an email notification :-/ — I'll dive into this.
In the meanwhile, I don't mind a quick fix here.
|
I'm in the progress of addressing this regression. But to be precise, this is not a bug. The documentation for
I will make sure to update the docs here as well, as that also needs the new NBSP and NNBSP added for PHP 8.2.x. |
If the exact number of whitespace is required then that makes it much, much harder to parse formats where day numbers are two space-padded characters: ...unless spaces are optional, which seems to be the case now? https://3v4l.org/IcBMe#v8.2.9 That aside, is there an actual problem with having a space represent one or more whitespace characters, as the behavior has been for the last 14 years? |
No, there is no problem with that at all, that's why we're keeping the behaviour, even though it wasn't originally intended. I've merged the fix now, and will now be updating documentation. |
This is very interesting, I never realized space actually matches one or more spaces. In theory, the correct fix would be to have one space match exactly one space (or tab) and have "j" match any of these: One could argue that this would be the correct behavior so you could match something like |
Is it too late to get this into 8.2.9? I noticed the docs were updated referencing a change in 8.2.9, but that change is maybe only in 8.2.10? |
PHP 8.2.9 tarballs rebuilt including that fix. |
I think by the way, the real source of the problem is somewhere different: this code (parsing the datetime) is run for re-formatting the output of Then Laravel tries parsing that with the format string So I guess either the Either way, it's great that the old behavior is restored to avoid unnecessary BC breaks. But out of curiosity, does anyone have some insight whether my thoughts go into the right direction? |
|
…time with extra space)
Description
Starting of 8.2.9 version
\DateTime:createFromFormat()
starts to fail to parse date format, due extra space.The date string
Wed Aug 2 08:37:50 2023
- with extra space betweenAug
and2
. If extra space is removedthen it works as usual.
PHP versions <8.2.9 correctly parses the format, I've tested with 8.2.7 version in addition to 8.2.8.
The following code:
Resulted in this output:
But I expected this output instead:
PHP Version
PHP 8.2.9
Operating System
No response
The text was updated successfully, but these errors were encountered: