On Sat, 14 Mar 2020 at 22:10, Larry Garfield <la...@garfieldtech.com> wrote:

> On Sat, Mar 14, 2020, at 10:40 AM, AllenJB wrote:
> > Hi all,
> >
> > A regular problem that new users run into is error handling with PDO.
> > The current default error mode for PDO is "silent". This leads to the
> > situation where code doesn't work and returns no obvious errors unless
> > PDO specific error handling code is explicitly added.
> >
> > I would like to propose the default error mode be changed from PHP 8 as
> > I believe this would make PDO error handling much more intuitive for new
> > developers, preventing the common "my code isn't working and I don't
> > know why" scenario that occurs.
> >
> > While a BC break, I believe it's the type of change developers expect in
> > a major version and I don't believe that explicitly setting the error
> > mode for code bases that rely on the silent error mode is onerous - many
> > code bases are already explicitly setting the error mode already.
> >
> > Given the way error handling has been / is heading in PHP, I would
> > suggest the default error mode should be exceptions, but I can forsee
> > arguments for using warnings instead ("less of a BC break" since code
> > would still continue unless a custom error handler causes an abort, so
> > closer to the behavior of "silent").
> >
> > What are peoples views on making this change?
> >
> > What do you think the new default be (and why)?
> >
> > (I am aware this change will likely require an RFC)
> >
> > AllenJB
>
> I see only two options:
>
> 1) Do nothing.
>
> 2) Move to Exceptions.
>
> I've never used PDO and not set it to Exceptions, honestly.  Adding more
> global error conditions to code is a terrible idea, so let's not do
> warnings.  If your query breaks, you really shouldn't continue because your
> data is busted so your following code will fail ungracefully at best, or
> corrupt data at worst.
>
> Changing a default like this seems a reasonably safe thing to do in a
> major, as long as it's still just as easy to switch back to silent mode for
> those who prefer to be explicit.
>
> --Larry Garfield
>
> --
> PHP Internals - PHP Runtime Development Mailing List
> To unsubscribe, visit: http://www.php.net/unsub.php


Agreed this should be an all or nothing change.

Best regards

George P. Banyard

Reply via email to