Skip to content

Fix the PDO::quote() null deprecation in Idiorm query logging on PHP 8.1+ #598

Closed

Description

@armanist

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() sets logging to is_debug_mode()), and lastQuery(), 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 a NULL parameter that is PDO::quote(null), which PHP 8.1 deprecates: "Passing null to parameter beautifying #1 ($string) of type string is deprecated".
  • ErrorHandler::handleError() throws an ErrorException for 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 NULL throws.

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.xml sets error_reporting to E_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 NULL parameter 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 phpstan and composer rector:check pass

Notes

Relevant code: src/Tracer/ErrorHandler.php, src/Database/Adapters/Idiorm/IdiormDbal.php, phpunit.xml.

Activity

  1. added this to the 3.1.0 milestone on Oct 23, 2026
  2. added
    bugSomething isn't working
    needs discussionNeeds design or product discussion before implementation
    on Oct 23, 2026
  3. self-assigned this
    on Oct 23, 2026
  4. added theissue type on Oct 23, 2026
  5. added a commit that references this issue on Oct 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingneeds discussionNeeds design or product discussion before implementation

Type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions