only a tiny subset of PDOException error codes are handled

Created on 24 May 2018, over 6 years ago
Updated 25 February 2023, over 1 year ago

Problem/Motivation

The mysql connection tries to handle error codes when the connection to the DB is first opened: in core/lib/Drupal/Core/Database/Driver/mysql/Connection.php:

    try {
      $pdo = new \PDO($dsn, $connection_options['username'], $connection_options['password'], $connection_options['pdo']);
    }
    catch (\PDOException $e) {
      if ($e->getCode() == static::DATABASE_NOT_FOUND) {
        throw new DatabaseNotFoundException($e->getMessage(), $e->getCode(), $e);
      }
      if ($e->getCode() == static::ACCESS_DENIED) {
        throw new DatabaseAccessDeniedException($e->getMessage(), $e->getCode(), $e);
      }
      throw $e;
    }

However, that's a tiny subset of the error codes.

For example, if using MAMP, the error is 2002, which is not picked up here.

List of error codes: https://dev.mysql.com/doc/mysql-errors/8.0/en/client-error-reference.html

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

📌 Task
Status

Postponed: needs info

Version

10.1

Component
Database 

Last updated less than a minute ago

  • Maintained by
  • 🇳🇱Netherlands @daffie
Created by

🇬🇧United Kingdom joachim

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇳🇿New Zealand quietone New Zealand

    Reading the issue summary this is not a functional bug. Therefor changing to a Task.

    I am not sure if the intention is to add exceptions for all the errors or just the one related to MAMP. Comment #9 explains why the current exceptions are handled and the others are not. The reasoning makes sense to me. At that time more information was asked for and none has been supplied, that was 11 months ago. There is also no supporting discussion for this change.

    Since we need more information to move forward with this issue, I am keeping the status at Postponed (maintainer needs more info). If we don't receive additional information to help with the issue, it may be closed after three months.

    Thanks!

Production build 0.71.5 2024