rfc:pdo_default_errmode

PHP RFC: Change Default PDO Error Mode

Introduction

The current default error mode for PDO is silent. This means that when an SQL error occurs, no errors or warnings may be emitted and no exceptions thrown unless the developer implements their own explicit error handling.

This causes issues for new developers because the only errors they often see from PDO code are knock-on errors such as “call to fetch() on non-object” - there's no indication that the SQL query (or other action) failed or why.

Proposal

This RFC proposes that the default PDO error mode by changed to PDO::ERRMODE_EXCEPTION in the next major PHP version.

The silent error mode will still be available for developers to explicitly switch to.

Backward Incompatible Changes

Existing code that does not explicitly set the PDO error mode and relies on the silent mode will be affected by this change. This code can be updated by explicitly setting the PDO error mode to silent.

Proposed PHP Version(s)

Next PHP x (PHP 8.0)

RFC Impact

To SAPIs

No changes to SAPIs.

To Existing Extensions

Existing extensions should not be affected (it is assumed any PDO extensions can already cope with error mode being set to exceptions).

To Opcache

No changes.

New Constants

This RFC introduces no new constants.

Open Issues

None.

Proposed Voting Choices

Voting starts 2020-04-13 and ends 2020-04-27

This vote requires a 2/3 majority.

Change the default PDO error handling mode to PDO::ERRMODE_EXCEPTION?
Real name Yes No
ajf Image 
alcaeus Image 
asgrim Image 
ashnazg Image 
beberlei Image 
brzuchal Image 
bwoebi Image 
carusogabriel Image 
colinodell Image 
cschneid  Image
danack Image 
daverandom Image 
derick Image 
duncan3dc Image 
duodraco Image 
ekin Image 
galvao Image 
geekcom Image 
girgias Image 
jasny Image 
jbnahan Image 
jhdxr Image 
kalle Image 
kelunik Image 
kguest Image 
klaussilveira Image 
kocsismate Image 
krakjoe Image 
lcobucci Image 
marandall Image 
marcio Image 
mariano Image 
mbeccati Image 
nicolasgrekas Image 
nikic Image 
ocramius Image 
peehaa Image 
petk Image 
pmjones Image 
pmmaga Image 
pollita Image 
ramsey Image 
reywob Image 
royopa Image 
ruudboon Image 
salathe Image 
sergey Image 
svpernova09 Image 
trowski Image 
yunosh  Image
zimt Image 
Final result: 49 2
This poll has been closed.

Patches and Tests

Implementation

(Pending implementation)

References

Rejected Features

None.

rfc/pdo_default_errmode.txt · Last modified: by 127.0.0.1

Image