exception 'DatabaseSchemaObjectExistsException' with message 'Table cache_entity_file already exists.'

Created on 25 July 2017, over 7 years ago
Updated 25 July 2023, over 1 year ago

It has observed that, entitycache creates tables during install under hook_schema() but tables are not droped during hook_uninstall()

This causes issues when module is disabled and someone try to enable it again.

This may leads to erro like:
exception 'DatabaseSchemaObjectExistsException' with message 'Table cache_entity_file already exists.'

🐛 Bug report
Status

Postponed: needs info

Version

1.0

Component

Code

Created by

🇬🇧United Kingdom dineshw London

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.

  • Open in Jenkins → Open on Drupal.org →
    Core: 7.x + Environment: PHP 7.4 & MySQL 5.7
    last update over 1 year ago
    268 pass, 16 fail
  • 🇬🇧United Kingdom mcdruid 🇬🇧🇪🇺

    Hmm, as mentioned in #2 I'm not certain we want to be dropping all the existing tables every time hook_schema is invoked.

    Manually testing this patch and installing, enabling and disabling entitycache I'm still hitting errors when drupal_flush_all_caches() tries to flush tables that no longer exist.

    We can keep adding workaround (e.g. check if the table exists before adding each bin in entitycache_flush_caches()) but I think perhaps it'd be better to try a slightly different approach to solving the problem.

    That may be as simple as dropping the tables in hook_uninstall(), but we'll want to check if that covers enabling/disabling too.

  • Status changed to Needs review over 1 year ago
  • Open in Jenkins → Open on Drupal.org →
    Core: 7.x + Environment: PHP 7.4 & MySQL 5.7
    last update over 1 year ago
    278 pass
  • 🇬🇧United Kingdom mcdruid 🇬🇧🇪🇺

    Here's a patch that drops the tables in hook_uninstall().

    However, this doesn't actually seem to be necessary AFAICS.

    https://api.drupal.org/api/drupal/modules%21system%21system.api.php/func... says:

    Database tables defined by hook_schema() will be removed automatically.

    ...and I've verified that works okay with some manual testing (using drush).

    When the module is disabled, the tables are not removed (which I think is the correct behaviour).

    I don't see any errors when the module is enabled again.

    So I'm not actually able to reproduce there being any problem with letting the install/enable/disable/uninstall API work as it does now alongside the existing hook_schema() implementation.

    Can anyone provide any steps to reproduce an error that requires a change in entitycache?

  • Status changed to Postponed: needs info over 1 year ago
  • 🇬🇧United Kingdom mcdruid 🇬🇧🇪🇺
Production build 0.71.5 2024