I was updating to 6.x-1.06.
user warning: Table 'MYDATABASENAME.variable' doesn't exist query: DELETE FROM variable WHERE name LIKE 'addresses_format_%' in /ETCETCETC/httpdocs/sites/all/modules/addresses/addresses.install on line 30.
The following queries were executed
addresses module
Update #6106
* Failed: DELETE FROM variable WHERE name LIKE 'addresses_format_%'
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | addresses-update.patch | 674 bytes | intuited |
Comments
Comment #1
codycraven commentedTyraelTLK,
The variable table is a Drupal core table. If you are missing this table it doesn't have anything to do with this module and may indicate a very big issue for which you should seek support in the #drupal-support channel on Freenode in IRC.
If your database does contain the table, although from your error it doesn't, please re-open this issue as it could indicate something wrong with the upgrade code.
Comment #2
intuited commentedHi,
There is a bug in the update function: the table name needs to be wrapped in braces. The code as it is will work okay for some people but people using table prefixes will get errors like the one TyraelTLK got. So the update function should be
/**
* Implementation of hook_update_N().
*/
function addresses_update_6106() {
// Clear address format's as tokens have changed
$ret[] = update_sql("DELETE FROM {variable} WHERE name LIKE 'addresses_format_%'");
return $ret;
}
In order to avoid getting the error, and for an easy way to ensure that the update routine actually does take place, you should be able to use the attached patch. You'll have to apply it after updating the module code and before doing the database update (ie before visiting http://your.site.com/update.php); once you've run the update, even if it reports errors, you won't be able to update again, at least not without restoring from a database backup or hacking the system database table.
If you have already updated to 1.06 and gotten errors, you just have to find another way to run that query. You can just plug it into the mysql command line client, but of course you'll have to use the full (prefixed) table name for {variables} -- mysql doesn't know anything about drupal's table prefixes and will just be confused by braces.
If you haven't run the update routine successfully you'll see strings like !street, !city, and !country instead of actual addresses when viewing address fields.
If somebody is going to roll this patch into the next release of addresses, they should be sure to put a similar (corrected with braces) query in a new update function for that version, so that people who have already updated to 1.06 and gotten errors will be able to have this code run successfully by updating to the next version. I think there's more information on this kind of stuff in the module maintainer's handbook. Probably the maintainer already knows this anyway.
Comment #3
abaddon commentedthis should really be fixed, i was updating from a previous version and.. i know you shouldnt modify update functions but in this case theres an error in it
Comment #4
codycraven commentedintuited,
Thank you for the catch - This update was created by another contributor before I had become a maintainer and when I looked at the issue I hadn't noticed the missing braces. I've updated addresses_update_6106 (so it will be in the next release) with your name as the credit.
For any users who are updating from 1.05 to 1.09 they should not encounter this issue if they are using table prefixes. If they have previously encountered this error they can re-run the update by manually selecting it for the addresses module on update.php.
abaddon,
Thank you for bringing this issue up again, I've been incredibly busy and would not have attended to the issue without you bringing it up.