Problem/Motivation
PHP 8.1 has fixed a bug in the PDO MySQL driver where if you use \PDO::ATTR_EMULATE_PREPARES then all fetches are string-ified. In PHP 8.1 integer db fields would return an integer value. However, all other core supported DBs are using the \PDO::ATTR_STRINGIFY_FETCHES option (to align with the behaviour of MySQL prior to PHP 8.1). See https://externals.io/message/113294 for further disucussion.
We could discuss changing this behaviour is future versions of Drupal. However this is likely to be a major version only change as it results in changing underlying data types and it extremely disruptive.
Steps to reproduce
See test runs in #3220021: [meta] Ensure compatibility of Drupal 9 with PHP 8.1 (as it evolves) - fixed in commit https://git.drupalcode.org/project/drupal/-/merge_requests/937/diffs?com...
Proposed resolution
Add \PDO::ATTR_STRINGIFY_FETCHES
to \Drupal\Core\Database\Driver\mysql\Connection::open()
Remaining tasks
User interface changes
None
API changes
None
Data model changes
None
Release notes snippet
Comment | File | Size | Author |
---|---|---|---|
#2 | 3224245-2.patch | 860 bytes | alexpott |
Comments
Comment #2
alexpottComment #3
mondrakeYes, this is the only possible fix for now I guess.
Comment #5
catchCommitted fd0b13a and pushed to 9.3.x. Thanks!
If we even want to remove this, it'll need to be after we require PHP 8.1, making it a 10.x+ change.
Comment #6
mondrakeComment #7
andypostSqlite and pgsql also affected because it's pdo change https://github.com/php/php-src/blob/php-8.1.0beta1/UPGRADING#L116
Comment #8
alexpott@andypost see issue summary - we already set this option for the other drivers.