php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #81405 Values of PDO::PARAM_ constants have changed
Submitted: 2021-09-01 09:07 UTC Modified: 2021-09-01 09:46 UTC
From: me at derrabus dot de Assigned:
Status: Closed Package: PDO Core
PHP Version: 8.1.0beta3 OS: macOS 11.5
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: me at derrabus dot de
New email:
PHP Version: OS:

 

 [2021-09-01 09:07 UTC] 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

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2021-09-01 09:14 UTC] 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:31 UTC] cmb@php.net
PHP 8.1.0RC1 is not yet *released*; we could re-tag if necessary.
 [2021-09-01 09:34 UTC] 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:46 UTC] nikic@php.net
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.
 [2021-09-01 10:29 UTC] me at derrabus dot de
Thank you very much!

(TIL: This bugtracker does not support emoji and replaces them with question marks that make my message look a lot more passive-agressive than I indended it to be <insert laughing emoji with sweat here>)
 [2021-09-01 11:55 UTC] git@php.net
Automatic comment on behalf of nikic
Revision: https://github.com/php/php-src/commit/1e012ecb3f888142cfe6366f4b17219c62a97d60
Log: Fix bug #81405: Restore old PDO::PARAM_* values
 [2021-09-01 11:55 UTC] git@php.net
-Status: Open +Status: Closed
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Oct 03 10:01:27 2024 UTC