Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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.'
Comment | File | Size | Author |
---|---|---|---|
#10 | 2897150-10.patch | 673 bytes | mcdruid |
| |||
#7 | exception-cache_entity_-already-exist-2897150-7.patch | 891 bytes | greggles |
#3 | exception-cache_entity_-already-exist-2897150-3.patch | 890 bytes | dineshw |
#2 | exception-cache_entity_$type-already-exist-2897150-2.patch | 1.04 KB | dineshw |
Comments
Comment #2
dineshw CreditAttribution: dineshw as a volunteer and at TATA Consultancy Services for Pfizer, Inc. commentedTrying to drop existing tables in case hook_schema() gets executed again.
Better approach could be using hook_uninstall().
Comment #3
dineshw CreditAttribution: dineshw as a volunteer and at TATA Consultancy Services for Pfizer, Inc. commentedUpdated Patch
Comment #4
dineshw CreditAttribution: dineshw as a volunteer and at TATA Consultancy Services for Pfizer, Inc. commentedComment #6
gregglesA small code style nitpick:
There needs to be a space after the `if` and before the `(`.
Comment #7
gregglesReroll to fix that.
Comment #9
mcdruidHmm, 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 workarounds (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.Comment #10
mcdruidHere'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:
...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?
Comment #11
mcdruid