On Wed, May 15, 2019 at 7:55 PM Matteo Beccati <p...@beccati.com> wrote:

> Hi Dan,
>
> On 15/05/2019 03:15, Dan Ackroyd wrote:
> > Immediately nothing.
> >
> > Eventually, when a __toString() method throws an exception, and the
> > extension doesn't check for an exception being throw, bad things will
> > happen.
> >
> > But in my opinion, if people don't understand the implications of the
> > RFC even after reading the details in the RFC and this thread, then
> > this probably is an RFC they should skip voting on.
>
> I don't agree. I've worked on a few bug fixes and features in php-src,
> but never worked directly with exceptions, so I have to admit my
> ignorance on the topic. I was expecting "bad things to happen", but I
> wasn't quite sure about it.
>
> "Extension authors who would like to ensure that they handle exceptions
> from string conversions gracefully" and "It is generally sufficient to
> check whether an exception has been thrown" do not convey any sense of
> urgency.
>
> Since there are many people who can vote and only do PHP userland, I
> believe that clarifying impact on the RFC itself would surely benefit
> everyone. Suggesting that they shouldn't vote is definitely not helping.
>

Quoting from the RFC:

> While checking every single string conversion certainly puts you on the
safe side, leaving out these checks will usually only result in some
unneeded computation and possibly redundant warnings. The main thing you
should watch out for are operations modifying persistent structures such as
databases.

Not explicitly handling exceptions from __toString() will not cause
segfaults or memory corruption if you don't do anything. It only means that
your function call will not abort at the earliest possible opportunity. If
you have functions modifying persistent datastores it's a good idea to
review them to make sure you handle exceptions right away, but otherwise I
wouldn't be overly concerned.

Nikita

Reply via email to