Bug #81405 [Opn]: Values of PDO::PARAM_ constants have changed

From: Date: Wed, 01 Sep 2021 09:46:42 +0000
Subject: Bug #81405 [Opn]: Values of PDO::PARAM_ constants have changed
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-236208@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=81405&edit=1 ID: 81405 Updated by: nikic@php.net Reported by: me at derrabus dot de Summary: Values of PDO::PARAM_ constants have changed Status: Open Type: Bug Package: PDO Core Operating System: macOS 11.5 PHP Version: 8.1.0beta3 Block user comment: N Private report: N New Comment: I've put up https://github.com/php/php-src/pull/7445 for the code change. Whether we land this or not is up to release managers. Previous Comments: ------------------------------------------------------------------------ [2021-09-01 09:34:54] me at derrabus dot de > In what way do Symfony and Doctrine use hard-coded values for PDO::PARAM_* constants? Doctrine DBAL has inlined the literal values when they decoupled the library from PDO: https://github.com/doctrine/dbal/blob/3.1.1/src/ParameterType.php The effect is that you _could_ still use the PDO constants when using prepared statements with DBAL, although you _should_ use the ParameterType constants instead. Symfony accidentally relied on that and I'm about to fix that now: https://github.com/symfony/symfony/pull/42819 However, my expectation would be that Symfony/Doctrine are not the only codebases where the assumption was made that those constants' values would perpetually remain the same. > If you had submitted this issue just one day earlier I'd have simply changed the values. I've been testing PHP 8.1 for quite a while now, but I literally discovered this issue last night. Sorry for being late. ???? ------------------------------------------------------------------------ [2021-09-01 09:31:19] cmb@php.net PHP 8.1.0RC1 is not yet *released*; we could re-tag if necessary. ------------------------------------------------------------------------ [2021-09-01 09:14:03] nikic@php.net In what way do Symfony and Doctrine use hard-coded values for PDO::PARAM_* constants? If you had submitted this issue just one day earlier I'd have simply changed the values. But ABI for PHP 8.1 is frozen now, and changing this would result in an ABI break. ------------------------------------------------------------------------ [2021-09-01 09:07:22] me at derrabus dot de Description: ------------ While patching the test suites of Symfony and Doctrine for PHP 8.1, I have discovered that the internal values of several PDO constants have changed. While I am aware that as a developer I should not rely on the value of those constants but rather use them as-is, I am afraid that this change might break existing application in interesting ways. My assumption is that the actual values of those constants should not matter much to PDO because they are used in switch-like constructs, but I might be wrong here. Under my assumption, the change feels a bit arbitrary and unnecessary. In the interest of providing a smooth upgrade path from PHP 8.0 to 8.1 for everyone, I'd kindly ask to restore the listed constants to their values from PHP 8.0. Test script: --------------- <?php echo 'PDO::PARAM_NULL => ' . \PDO::PARAM_NULL . "\n"; echo 'PDO::PARAM_BOOL => ' . \PDO::PARAM_BOOL . "\n"; echo 'PDO::PARAM_INT => ' . \PDO::PARAM_INT . "\n"; echo 'PDO::PARAM_STR => ' . \PDO::PARAM_STR . "\n"; echo 'PDO::PARAM_LOB => ' . \PDO::PARAM_LOB . "\n"; echo 'PDO::PARAM_STMT => ' . \PDO::PARAM_STMT . "\n"; Expected result: ---------------- PDO::PARAM_NULL => 0 PDO::PARAM_BOOL => 5 PDO::PARAM_INT => 1 PDO::PARAM_STR => 2 PDO::PARAM_LOB => 3 PDO::PARAM_STMT => 4 Actual result: -------------- PDO::PARAM_NULL => 0 PDO::PARAM_BOOL => 1 PDO::PARAM_INT => 2 PDO::PARAM_STR => 3 PDO::PARAM_LOB => 4 PDO::PARAM_STMT => 5 ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=81405&edit=1

« previous php.bugs (#236208) next »