Metatag 1.7 adds a revision_id column and includes an update function to set the revision ID for all existing metatag rows. This update function is broken for multilingual sites using entity_translation. In the update function, for each row in the metatag table, the corresponding node is loaded with a condition on the language of the metatag row. However, for sites using entity_translation, there is only one row in the node table for each piece of content, not one for each language. Therefore, only metatags records in the default language are updated, rows corresponding to a translated version are skipped.
Attached patch fixes the update function. The patch is against version 1.7 and does NOT include a new update function. On the site where I had this problem, I didn't want to update to the dev version of metatag, therefore I added the following to a custom module to re-run the (now fixed) update. Re-running the update function is not a problem, it checks if there is anything to do before trying to do the work.
function my_custom_module_update_7001(&$sandbox) {
metatag_update_7018($sandbox);
}
This could easily be adapted to metatag.install in metatag-7.x-1.x, all that has to be changed is the function name.
| Comment | File | Size | Author |
|---|---|---|---|
| #12 | metatag-n2603458-12.patch | 1.03 KB | damienmckenna |
Comments
Comment #2
Frando commentedHere's a proper patch to metatag-7.x-1.x.
Comment #6
Frando commentedComment #8
damienmckennaUgh, sorry about that :(
Comment #9
damienmckennaShould the new update script only run if entity_translation is enabled?
Comment #10
Frando commentedNot sure if there are other situations where this might happen (e.g. custom translation modules or an entity_translation successor or dunno). For sites where the update has already run successfully, it is basically a no-op, so I think there's no harm in just running it for everyone.
Comment #11
damienmckennaI was able to confirm the problem with entity_load() using the following code:
Comment #12
damienmckennaRerolled, and improved the comment.
Comment #15
damienmckennaCommitted. Thanks!