Skip to content

Add forward compatibility for PDO MySQL driver constants#99

Merged
lippserd merged 3 commits intomainfrom
pdo-driver-consts-forward-compat
Mar 10, 2026
Merged

Add forward compatibility for PDO MySQL driver constants#99
lippserd merged 3 commits intomainfrom
pdo-driver-consts-forward-compat

Conversation

@lippserd
Copy link
Member

@lippserd lippserd commented Mar 9, 2026

PHP 8.4 introduced driver-specific PDO MySQL constants on Pdo\Mysql, and
PHP 8.5 deprecates accessing those constants through the generic PDO class.

Add a forward-compatibility shim that provides Pdo\Mysql::ATTR_* on older PHP
versions when pdo_mysql is available. The shim mirrors the mysqlnd and
non-mysqlnd differences in available constants so existing code can switch to
the driver-specific API without dropping support for older runtimes.

lippserd added 3 commits March 9, 2026 15:43
PHP 8.4 introduced driver-specific `PDO` MySQL constants on `Pdo\Mysql`, and
PHP 8.5 deprecates accessing those constants through the generic `PDO` class.

Add a forward-compatibility shim that provides `Pdo\Mysql::ATTR_*` on older PHP
versions when pdo_mysql is available. The shim mirrors the mysqlnd and
non-mysqlnd differences in available constants so existing code can switch to
the driver-specific API without dropping support for older runtimes.
This reverts commit 8520935.

The shim introduced in 074d118 allows us to use `PDO` MySQL driver-specific
constants, which will be introduced in a subsequent commit.
Replace deprecated `PDO::MYSQL_*` constant usage with the driver-specific
`Pdo\Mysql::ATTR_*` constants introduced in PHP 8.4.

This prepares the code for PHP 8.5, where accessing MySQL driver constants
through the generic `PDO` class is deprecated.

This change requires the compatibility shim (074d118) on older PHP versions to
provide `Pdo\Mysql` for runtimes that do not expose the driver-specific class
yet.
Copy link
Contributor

@BastianLedererIcinga BastianLedererIcinga left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, tested in on 8.3, 8.4 and 8.5 and got no warnings.

@lippserd
Copy link
Member Author

Looks good, tested in on 8.3, 8.4 and 8.5 and got no warnings.

Can you adapt other repositories in which changes regarding the PDO constants have already been merged or are open?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants