Problem/Motivation

$ php -m|grep pdo_mysql
$ vendor/bin/phpstan analyze --no-progress -c core/phpstan.neon.dist core/modules/mysql/src/Driver/Database/mysql/Connection.php
 ------ ------------------------------------------------------------------------------------------------------------------------------------------------ 
  Line   Connection.php                                                                                                                                  
 ------ ------------------------------------------------------------------------------------------------------------------------------------------------ 
  125    Array has 3 duplicate keys with value 0 (\Pdo\Mysql::ATTR_USE_BUFFERED_QUERY, \Pdo\Mysql::ATTR_FOUND_ROWS, \Pdo\Mysql::ATTR_MULTI_STATEMENTS).  
         🪪  array.duplicateKey                                                                                                                          
 ------ ------------------------------------------------------------------------------------------------------------------------------------------------ 


                                                                                                                        
 [ERROR] Found 1 error                                                                                                  

There is no error if pdo_mysql is available.

Steps to reproduce

Proposed resolution

Add the array entries separately, so PHPStan doesn't consider the duplicates:

    $connection_options['pdo'][\PDO::ATTR_ERRMODE] = \PDO::ERRMODE_EXCEPTION;
    $connection_options['pdo'][Mysql::ATTR_USE_BUFFERED_QUERY] = TRUE;
    $connection_options['pdo'][Mysql::ATTR_FOUND_ROWS] = TRUE;
    $connection_options['pdo'][\PDO::ATTR_EMULATE_PREPARES] = TRUE;
    $connection_options['pdo'][Mysql::ATTR_MULTI_STATEMENTS] = FALSE;
    $connection_options['pdo'][\PDO::ATTR_STRINGIFY_FETCHES] = TRUE;

Remaining tasks

User interface changes

Introduced terminology

API changes

Data model changes

Release notes snippet

Issue fork drupal-3570857

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

longwave created an issue. See original summary.

longwave’s picture

Priority: Normal » Major
Status: Active » Needs review

Bumping to major as this is affecting core committers.

The suggested solution isn't quite correct because settings.php can override these if they really want, so we have to allow the same.

Let's also remove the ableist language while we're here.

longwave’s picture

Also opened https://github.com/phpstan/phpstan/issues/14041 to solve it from the PHPStan side as really I think this is a bug there.

godotislate’s picture

Status: Needs review » Reviewed & tested by the community

Changes are very straightforward. Upstream test failure resolved by rebase. lgtm

  • larowlan committed f0792ef3 on main
    fix: #3570857 PHPStan fails if pdo_mysql is not installed
    
    By: longwave
    

larowlan’s picture

Status: Reviewed & tested by the community » Fixed

Committed to main - thanks!

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.