PDO::FETCH_CLASS + FETCH_CLASSTYPE ignores constructor args in PHP 8.5.0, fixed in 8.5.2
Found this the hard way. After upgrading to 8.5.0, queries using FETCH_CLASS combined with FETCH_CLASSTYPE silently stopped passing constructor arguments to the class constructor. The third argument to fetchAll() was ignored with no error.
This is a regression tracked in GitHub issue GH-20553. It was fixed in 8.5.2. If you are on 8.5.0 or 8.5.1 and your ORM layer or data mapper passes dependencies through the PDO constructor args mechanism, those objects will be in a broken state since the constructor never ran with the right arguments. No exception, no warning, just silently wrong objects.
Upgrading to 8.5.2 fixes it. Alternatively, skip 8.5.0 and 8.5.1 entirely if you have not upgraded yet.
Thanks for posting this. We were about to deploy 8.5.0 to staging tomorrow. Will update the Dockerfile to 8.5.2 before running any tests.
We ran into a related change too: PDO::ATTR_STRINGIFY_FETCHES now converts booleans to “0” and “1”. Before 8.5 it did not touch booleans when STRINGIFY_FETCHES was on. We had tests checking strict equality against false from PDO results that all started failing after the upgrade.
@bohdan_v yeah that one also got us. The fix is straightforward once you know what changed, but connecting failing tests to a PDO attribute behavior change is not obvious. Took a while to track down.
```php blocks are runnable.