Re: [PHP-DEV] Remove warning when parsing datetime with + symbol?

2022-11-28 Thread Paul Dragoonis
On Mon, 28 Nov 2022, 16:32 Christoph M. Becker,  wrote:

> On 28.11.2022 at 16:50, Derick Rethans wrote:
>
> > On Thu, 24 Nov 2022, mickmackusa wrote:
> >
> >> Can anyone explain to me why it is desirable/beneficial for the DateTime
> >> class to store a warning that trailing characters were ignored while
> >> parsing a date/time string with the + symbol in createFromFormat()?
> >
> > I have no idea why I decided that was a good idea back all these years,
> > and I'm perfectly happy to remove that restriction from PHP 8.3
> > forwards — it's too late to do that in PHP 8.2 now, as it's being
> > released next week.
>
> That would appear to consitute a BC break.  From the docs:
>
> | If this format specifier is present, trailing data in the string will
> | not cause an error, but a warning instead
>
> This can be used to parse the date (without the +, parsing may fail),
> but still be able to return a message about ignored characters to the user.
>

We are allowed to break BC in minor version upgrades, Chris.

We can allow this is 8.3 I think, rather than waiting for 9.0

What do you think?



> --
> Christoph M. Becker
>
> --
> PHP Internals - PHP Runtime Development Mailing List
> To unsubscribe, visit: https://www.php.net/unsub.php
>
>


Re: [PHP-DEV] Remove warning when parsing datetime with + symbol?

2022-11-28 Thread Christoph M. Becker
On 28.11.2022 at 16:50, Derick Rethans wrote:

> On Thu, 24 Nov 2022, mickmackusa wrote:
>
>> Can anyone explain to me why it is desirable/beneficial for the DateTime
>> class to store a warning that trailing characters were ignored while
>> parsing a date/time string with the + symbol in createFromFormat()?
>
> I have no idea why I decided that was a good idea back all these years,
> and I'm perfectly happy to remove that restriction from PHP 8.3
> forwards — it's too late to do that in PHP 8.2 now, as it's being
> released next week.

That would appear to consitute a BC break.  From the docs:

| If this format specifier is present, trailing data in the string will
| not cause an error, but a warning instead

This can be used to parse the date (without the +, parsing may fail),
but still be able to return a message about ignored characters to the user.

--
Christoph M. Becker

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: https://www.php.net/unsub.php



Re: [PHP-DEV] Microseconds to error log

2022-11-28 Thread Derick Rethans
On Fri, 21 Oct 2022, Mikhail Galanin via internals wrote:

> (4) Derrek Rethans suggested introducing a new function (e.g.
> php_format_date_ex) that
>  takes care of usecs (see the thread on Github)

It's 'Derick' :-)

> Looking into the future, probably we would like to have this format 
> configurable, if so it looks easy to do but still I can't see an easy 
> way to handle the microseconds issue.

Making things configurable requires an ini setting, which we generally 
don't like to add. It wouldn't really work in this situation, as 
warnings/errors happen either before or during INI file parsing, meaning 
that it can't (yet) use the new format.

> Could you please help me to find the right way and share your thoughts 
> about this topic (maybe there are strong objections against such a 
> change)?

I don't think we should change anything in PHP. Instead, use your 
system's syslog. You can configure PHP to send all warnings to syslog by 
setting "log_errors=1 error_log=syslog" in PHP.ini. In order to separate 
out just the PHP issues, you can also set "syslog.facility=local1" (or 
any other local).

On Unix systems, you can configure syslog to add milliseconds to the log 
file messages. See  https://askubuntu.com/a/1266114

If your system already uses systemd and journald, then you don't have to 
use any configuration settings, and you can query the journal with:

journalctl -o short-iso-precise -r --facility=local1

A PHP warning would show up in there, with something like:

$ sudo journalctl -o short-iso-precise -r --facility=local1
2022-11-28T16:06:53.862980+ gargleblaster php[3143059]: PHP Warning:  
Undefined variable $fasd in Command line code on line 1

cheers,
Derick

-- 
https://derickrethans.nl | https://xdebug.org | https://dram.io
Author of Xdebug. Like it? Consider supporting me: https://xdebug.org/support
Host of PHP Internals News: https://phpinternals.news
mastodon: @derickr@phpc.social @xdebug@phpc.social
twitter: @derickr and @xdebug

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: https://www.php.net/unsub.php



Re: [PHP-DEV] Remove warning when parsing datetime with + symbol?

2022-11-28 Thread Derick Rethans
On Thu, 24 Nov 2022, mickmackusa wrote:

> Can anyone explain to me why it is desirable/beneficial for the DateTime
> class to store a warning that trailing characters were ignored while
> parsing a date/time string with the + symbol in createFromFormat()?

I have no idea why I decided that was a good idea back all these years, 
and I'm perfectly happy to remove that restriction from PHP 8.3 
forwards — it's too late to do that in PHP 8.2 now, as it's being 
released next week.

cheers,
Derick

-- 
PHP 7.4 Release Manager
Host of PHP Internals News: https://phpinternals.news
Like Xdebug? Consider supporting me: https://xdebug.org/support
https://derickrethans.nl | https://xdebug.org | https://dram.io
twitter: @derickr and @xdebug

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: https://www.php.net/unsub.php