Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to check PDO::ATTR_STRINGIFY_FETCHES configuration #12969

Closed
janedbal opened this issue Dec 18, 2023 · 4 comments
Closed

Unable to check PDO::ATTR_STRINGIFY_FETCHES configuration #12969

janedbal opened this issue Dec 18, 2023 · 4 comments

Comments

@janedbal
Copy link

Description

The following code:

<?php
$pdo = new PDO('mysql:host=mysql;port=3306', 'root', 'secret');
var_dump(
    $pdo->getAttribute(PDO::ATTR_STRINGIFY_FETCHES)
);

Resulted in this output:

Fatal error: Uncaught PDOException: SQLSTATE[IM001]: Driver does not support this function: driver does not support that attribute in /app/pdo.php on line 3

But I expected this output instead:

int(0);

It seems like I cannot verify how PDO is configured regarding this option. When $pdo->setAttribute(PDO::ATTR_STRINGIFY_FETCHES, true) is used, true is returned and the behaviour changes. This behaviour applies for at least mysql, pgsql and sqlite.

Full dockerized replication repository: https://github.com/janedbal/php-pdo-get-attribute-bug

PHP Version

PHP 8.3.0

Operating System

No response

@SakiTakamachi
Copy link
Member

This is a known issue. In #12793 I made a fix for this issue on master. I targeted the master branch for changes because there were some other existing behavior changes.

@Girgias
At least regarding the part of getting PDO::ATTR_STRINGIFY_FETCHES with getAttribute(), I don't think it will cause a BC break even if we backport it. What do you think?

@janedbal
Copy link
Author

Thx, I'd love to see this backported!

Currently I'm working on phpstan-doctrine feature that attempts to autodetect stringification behaviour and this is blocking issue for me.

@SakiTakamachi
Copy link
Member

I have created the backport PR to 8.2 for the time being.

#12970

nielsdos added a commit that referenced this issue Dec 22, 2023
* PHP-8.2:
  Fix GH-12969: Fixed PDO::getAttribute() to get PDO::ATTR_STRINGIFY_FETCHES
nielsdos added a commit that referenced this issue Dec 22, 2023
* PHP-8.3:
  Fix GH-12969: Fixed PDO::getAttribute() to get PDO::ATTR_STRINGIFY_FETCHES
@janedbal
Copy link
Author

Thanks!

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

No branches or pull requests

2 participants