Problem/Motivation

Relating to: https://www.drupal.org/project/drupal/issues/3267203

The tableExists ignores all exceptions, rather than checking if the exception is the table not existing. This can, as noted in the related ticket, cause Drupal to think a table is missing when in fact it has just lost connection to the database, and subsequently it will redirect to the installer page.

Steps to reproduce

Add a sleep before the tableExists and shutdown the MySQl database server whilst PHP is sleeping. tableExists will then return false instead of throwing an exception due to the loss of connection.

If this occurs during shouldRedirectToInstaller inside InstallerRedirectTrait it will cause a redirect to the installer page.

Proposed resolution

Throw exception on error, and only return false if the table existence check succeeded and the table does not exist.

Or complete https://www.drupal.org/project/drupal/issues/2797141 which removes the exception handling altogether and reverts, however that issue might be blocked by an underlying MySQL issue.

Remaining tasks

-

User interface changes

None

API changes

None

Data model changes

None

Release notes snippet

None

Issue fork drupal-3267207

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

Driskell created an issue. See original summary.

driskell’s picture

Status: Active » Needs review
alexpott’s picture

@Driskell would you mind rolling closing this as a duplicate of #2797141: Remove the methods tableExists() and fieldExists() from Drupal\Core\Database\Driver\mysql\Schema and rolling a fresh patch for that fix. I think it is the correct one here. The performance questions have been answered so it'll be great to get that one done.

driskell’s picture

Status: Needs review » Closed (duplicate)

@alexpott Sure I can just close this. I was just concerned that issue had lost traction due to the issue being still present - but let's assume it is not an issue and I'll link this together. It would be extremely beneficial to get that one merged especially if it is faster.

The patch in https://www.drupal.org/project/drupal/issues/2797141 will resolve this issue unchanged as the default tableExists from global schema does not capture exceptions.

- Duplicate of : https://www.drupal.org/project/drupal/issues/2797141

alexpott’s picture

@Driskell thanks! I think it just got lost in the masses of open issues.