Problem/Motivation

Discovered via PHPStan in #3178534: Start running PHPStan on Drupal core (level 0):

  Line   core/lib/Drupal/Core/Database/Driver/mysql/Connection.php                         
 ------ ---------------------------------------------------------------------------------- 
  102    Class Drupal\Core\Database\Driver\mysql\StatementInterface not found.             

Line 102 of Drupal\Core\Database\Driver\mysql\Connection::handleQueryException() is:

      $query_string = ($query instanceof StatementInterface) ? $query->getQueryString() : $query;

StatementInterface does not exist in this namespace, but at Drupal\Core\Database\StatementInterface.

Steps to reproduce

Proposed resolution

Add the missing use statement.

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

CommentFileSizeAuthor
#2 3205024.patch664 byteslongwave
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

longwave created an issue. See original summary.

longwave’s picture

Status: Active » Needs review
FileSize
664 bytes
mondrake’s picture

Status: Needs review » Reviewed & tested by the community

Good catch.

  • catch committed 6d0f2eb on 9.2.x
    Issue #3205024 by longwave: Missing use statement in Drupal\Core\...

  • catch committed 559f22c on 9.1.x
    Issue #3205024 by longwave: Missing use statement in Drupal\Core\...
catch’s picture

Version: 9.2.x-dev » 9.1.x-dev
Status: Reviewed & tested by the community » Fixed

Nearly asked for test coverage here, but we only use this check to build the error message for an exception, and we've additionally already done #3137883: Deprecate passing a StatementInterface object to Connection::query. So I think we should just go ahead here.

Committed 6d0f2eb and pushed to 9.2.x + cherry-picked to 9.1.x. Thanks!

Status: Fixed » Closed (fixed)

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