Repository navigation
Labels
bugSomething isn't workingSomething isn't workingneeds discussionNeeds design or product discussion before implementationNeeds design or product discussion before implementation
Milestone
Description
Summary
On PHP 8.1 and newer, a query with a NULL bound parameter raises a deprecation when Idiorm logs it. Quantum's error handler turns a reported deprecation into an exception, so the query fails. Found while raising the minimum PHP version (#595).
Current state
- Query logging is on in debug mode (
IdiormDbal::getBaseConfig()setsloggingtois_debug_mode()), andlastQuery(),queryLog()and the debug toolbar's queries tab depend on it. - Idiorm 1.5.8 (the last release) builds the logged query with
array_map([$db, 'quote'], $parameters)in_log_query(). With aNULLparameter that isPDO::quote(null), which PHP 8.1 deprecates: "Passing null to parameter beautifying #1 ($string) of type string is deprecated". ErrorHandler::handleError()throws anErrorExceptionfor every reported error, deprecations included. PHP reports them by default in development (error_reporting = E_ALL).- Result: on 8.1+, in debug mode, any query that binds
NULLthrows.
Evidence
- Running the test suite on PHP 8.1 with deprecations reported fails 50 tests with this message; the same run on PHP 8.0 passes.
- The normal suite does not show it, because
phpunit.xmlsetserror_reportingtoE_ALL & ~E_DEPRECATED.
Why it cannot be fixed with a subclass
Idiorm calls its logging as self::_log_query(), so overriding the method in a subclass has no effect.
Proposed direction
Decide how ErrorHandler should treat E_DEPRECATED and E_USER_DEPRECATED. A deprecation is a warning about the future, not a failure, so reporting it (for example logging it) instead of throwing keeps applications running on newer PHP versions. To be agreed in this ticket.
Acceptance criteria
- a debug-mode query with a
NULLparameter works on PHP 8.1 and newer with deprecations reported - the behavior for deprecations is covered by a test that fails before the fix
- if the error handler changes, the docs for the Tracer package describe it
composer test,composer cs:check,composer phpstanandcomposer rector:checkpass
Notes
Relevant code: src/Tracer/ErrorHandler.php, src/Database/Adapters/Idiorm/IdiormDbal.php, phpunit.xml.
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingneeds discussionNeeds design or product discussion before implementationNeeds design or product discussion before implementation
Activity
[#598] Log deprecations in the error handler instead of throwing them