Hi, I've just updated the metatag module to the latest -beta3 but I've found a problem. Fortunately I've done a backup before the update :-) .

The -beta3 version adds a new "language" column to metatag table and every existing record is set to the default site language (on my website it has been set to "it", which is the default site language).

But when I create a new node the language field is filled with "und": I'm not using i18n and entity translation modules.

And now the bug: when you view a node the meta tag is visible in the HTML source code but when you open the node editing form the meta tag description field is filled with the default value "[node:summary]" instead of the value stored on the db (probably because it looks for "und" records, not "it").

I've tried to manually set the language field directly on the table but it doesn't fix the problem, I suppose that the binary blob contains some other data, I've not checked it yet

Now I'm reverting the DB and the old module version, I really hope for a cleaner upgrade path.

Thanks for the attention.

Files: 
CommentFileSizeAuthor
#11 metatag-n1842868-11.patch8.99 KBDamienMcKenna
PASSED: [[SimpleTest]]: [MySQL] 11 pass(es).
[ View ]
#7 metatag-n1842868-7.patch5.17 KBDamienMcKenna
PASSED: [[SimpleTest]]: [MySQL] 11 pass(es).
[ View ]
#3 metatag-n1842868-3.patch5.19 KBDamienMcKenna
PASSED: [[SimpleTest]]: [MySQL] 11 pass(es).
[ View ]

Comments

Priority:Major» Critical

Argh, the translation system has taken a bite. I'll see if I can fix this and roll out a beta4 soon.

@DamienMcKenn: thanks :-)

I'd like to share some simple thoughts about this issue:

*1) When updating the DB with metatag_update_7003(), instead of setting existing nodes to the default language would be possible to set the language field to the same language of each node?

*2) Why not update existing records data adding the correct language? The metatag data stores the language, so the update process should load the data and set the language like *1).

We have at least three scenarios:

A) single language website: my suggestions could be a simple way to solve the upgrade problem from a previous meta tag version :-)

B) multi language websites using i18n: meta tag data depends on the node language, and my suggestion could still be right.

C) multi site language websites using entity translation: probably in this case metatag module is not used because the entity translation support has just been added.... :-)

Thanks again for your attention and for the feedback!

StatusFileSize
new5.19 KB
PASSED: [[SimpleTest]]: [MySQL] 11 pass(es).
[ View ]

Ok, please try this on a backup of your site.

This resolves three things:

  • It fixes metatag_update_7003() so that each entity has its language assigned to that object's correct language value, as it should have been to start with and as you correctly suggest.
  • It adds metatag_update_7004() to go back and update all entities that had the language set incorrectly, they'll now have a new language value assigned per the above. Note that if someone has already created a replacement value then the newer value will be removed in favor of the previous value.
  • It changes metatag_metatags_view() to check if there are LANGUAGE_NONE meta tag values for the current entity rather than just giving up if there aren't any for the current selected language.

Please give a test on a backup of your site and let me know how it goes, if it works for you I'll roll this out immediately as beta4.

Status:Active» Needs review

Hi @DamienMcKenna, I've started doing the following test:

1) updated to beta3
2) updated the database
3) applied the patch
4) re-run the database update

update.php returns this error:

    Failed: PDOException: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'm.language' in 'where clause': DELETE FROM {metatag} WHERE (m.language = :db_condition_placeholder_0) AND (m.entity_type = :db_condition_placeholder_1) AND (m.entity_id = :db_condition_placeholder_2) ; Array ( [:db_condition_placeholder_0] => und [:db_condition_placeholder_1] => node [:db_condition_placeholder_2] => 1 ) in metatag_update_7004() (line 315 of /var/www/example.com/sites/all/modules/contrib/metatag/metatag.install).

The patch makes a wrong use of db_delete and db_update: those method does not require to set the alias on the working table but the conditions are "m.field_name" instead of "field_name". Probably a wrong copy/paste from the select method.

Anyway, after manually fixing the patch and re-running it the problem seems fixed. Would you like to repost a new patch with the corrected queries? I will test it again and this time I will try to update from an older metatag module version too.

Thanks :-)

P.S: don't try to change the db_update()/db_delete() adding the "m" alias like db_select(), it doesn't work because both require an array as second parameter:

db_update($table, array $options = array())

db_delete($table, array $options = array())

StatusFileSize
new5.17 KB
PASSED: [[SimpleTest]]: [MySQL] 11 pass(es).
[ View ]

Gah, should have caught the query problem. Thanks.

Great, this patch works as expected, thanks :-)

Status:Needs review» Needs work

I've committed the patch from #7 but I want to add proper BatchAPI usage before releasing the next beta.

You're right, it should be better. Thanks :-)

Status:Needs work» Needs review
StatusFileSize
new8.99 KB
PASSED: [[SimpleTest]]: [MySQL] 11 pass(es).
[ View ]

This patch does two things:

  • Update 7003 is trimmed down to only add the missing field.
  • Update 7004 is changed so it will update all records, and it uses the Batch API.

I think this will cover both a) sites that weren't updated to beta3 yet, b) sites that were updated and possibly have some borked content.

Status:Needs review» Needs work

The last submitted patch, metatag-n1842868-11.patch, failed testing.

Version:7.x-1.0-beta3» 7.x-1.x-dev

Status:Needs work» Needs review

#11: metatag-n1842868-11.patch queued for re-testing.

Status:Needs review» Fixed

I've committed the patch from #11.

FYI I tested this on a demo site with ~7000 nodes with different language values, it all seems to work ok.

I've released beta4, hopefully all will go well with the new release :)

Thanks again @DamienMcKenna :-)

Status:Fixed» Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

Not related to this issue, but exactly the same symptoms and thus Google brought me here, so for anybody else who ends up here with disappearing metatags but is not solved by the code update on this issue.

If you have administration language installed make sure admin_language_force_neutral is set to false in the administration languages page, otherwise administration languages unsets the language on the node, and metatags inserts the metatag record with undefined langauge. This, you can update your metatags, but only once and thereafter when you edit the node, the edit form is empty.

@willieseabrook: Thanks for identifying the problem, I've opened a new issue to work on improving compatibility, or at least provide a Huge Big Warning Message(tm): #1995564: Add warning about using Administrative Language module

Issue summary:View changes

Removed unnecessary info and explained a bit better the bug.