This is an old revision of the document!
PHP RFC: Change Default PDO Error Mode
- Version: 1.0
- Date: 2020-03-28
- Author: AllenJB, php.lists@allenjb.me.uk
- Status: Voting
- First Published at: http://wiki.php.net/rfc/pdo_default_errmode
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
This RFC has no impact on SAPIs, extensions or Opcache.
To Existing Extensions
Will existing extensions be affected?
To Opcache
It is necessary to develop RFC's with opcache in mind, since opcache is a core extension distributed with PHP.
Please explain how you have verified your RFC's compatibility with opcache.
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.
Patches and Tests
Not provided.
Implementation
(Pending implementation)
References
- Initial internals discussion: https://externals.io/message/109015
- RFC discussion thread: https://externals.io/message/109398
Rejected Features
None.