Problem/Motivation
Any sites that upgraded from the defunct Metatags (plural) module from 2011, and who did not uninstall the module properly, end up with a {metatag} table that is out of date and causes the site to error out on pretty much every page load. A key problem problem with resolving this is that it can't be resolved during hook_install() as the schema will already be loaded; besides which, it could involve a lot of data manipulation and there's no way of running the Batch API during hook_install().
Proposed resolution
Either:
- Use hook_requirements to check if the tables already exist and are not up to spec, delete the tables if they are empty or rename them if they contain data; this would need a follow-on task to provide some method of importing/migrating the data.
- Do something similar only from hook_schema().
- Do nothing. This isn't a particularly good idea as it leaves sites potentially broken.
- Other ideas?
Remaining tasks
- Identify the best approach to take.
- Build & test a patch.
User interface changes
Unsure.
Original report by @username
I have usedon a long develop website metags (That was 6 month ago).
Today I have mistakely download metatag to /modules as well and even instal it!
When I have discoverd I unintall metatags and delete the module files + clear cache.
Then I reinstal metatag, run update.php and it's seems fine.
But - I get fatal error on all pages except admin pages.
The error in the log messeges:
PDOException: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'instance' in 'where clause': SELECT t__0.* FROM {metatag_config} t__0 WHERE (instance IN (:db_condition_placeholder_0, :db_condition_placeholder_1, :db_condition_placeholder_2)) ; Array ( [:db_condition_placeholder_0] => node:page [:db_condition_placeholder_1] => node [:db_condition_placeholder_2] => global ) in ctools_export_load_object() (line 427 of /home/maayan/public_html/sites/all/modules/ctools/includes/export.inc).
Any idea?
| Comment | File | Size | Author |
|---|---|---|---|
| #14 | metatag-n1391554-14.patch | 2.69 KB | damienmckenna |
Comments
Comment #1
dave reidDid you uninstall the module via admin/modules/uninstall before you deleted the module files?
Comment #2
amirtaiar commentedYes.
I disabled the module >> then admin/module/uninstall >> delete the file.
Comment #3
damienmckenna@amirtaiar: Sorry for the lack of response. How were you able to resolve the problem?
Comment #4
damienmckennaIt might be worth adding something to the install script to look for an old schema.
Comment #5
damienmckennaThinking through it I'm not sure that would work - the installation will fail as the table already exists, which would cause it to not run any hook_install function.. maybe a custom task to be fired from hook_requirements? Hrm..
Comment #6
damienmckennaReviewing the codebase, the only time that the metatag_config table did *not* have an "instance" field was v7.x-1.0-unstable1 from August 16th, 2011, i.e. the very first basebones release of the module when it had only ten commits, and it was changed 13 days later on August 29th.
I'm not going to work on this right now, but if anyone wants to put some work into it I'd be happy to include any working patches.
Comment #7
damienmckennaClosed a duplicate: #2221181: Correctly handle upgrades from Metatags module
Comment #8
damienmckennaI'm proposing adding code to hook_install that either:
Any thoughts on which path to take?
Comment #9
damienmckennaA third option would be:
Comment #10
damienmckennaBumping this to 1.0 so that 1.0-rc1 can be released pronto.
Comment #11
damienmckennaI'm honestly not sure how to do this. I think renaming the tables might be the best option, but the question is - where to do so? During hook_requirements() where $phase == 'install'? It wouldn't work during hook_install() as the schema will already have been loaded.
Comment #12
damienmckennaI've updated the issue summary.
Comment #13
greg boggsA 4th option which would be good if no other option has been completed, detect the old tables and link to this page that explains the problem and the work needed to resolve it.
Comment #14
damienmckennaHows about this? It checks during hook_requirements() when $phase == 'install' - if the table is found and is missing one of the columns it will rename the table, but if the table is empty is imply removes it.
Comment #15
damienmckennaOther considerations:
Comment #17
damienmckennaCommitted. This will at least prevent sites blowing up and it can be improved upon later.