Currently Metatag stores its data as $entity->metatag[metatag_name], as compared to core data that is stored as e.g. $entity->field_name[langcode][0][value]; Metatag should be updated to store its data in the same way as other data structures to make some types of data handling easier, including translations.

CommentFileSizeAuthor
#3 metatag-n1876034-3.patch809 bytesDamienMcKenna
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Jax’s picture

Title: Ensure $entity->metatags can be saved programmatically from a loaded entity only » Change $entity->metatags object to match core data handling
Priority: Major » Normal
Status: Needs review » Active
Issue tags: -D7 stable release blocker

Just some more info related to this, in metatag_metatags_save():

  // Certain modules, e.g. Workbench Moderation, will cause the data to be in
  // an unsupported format; the problem needs to be resolved elsewhere so this
  // can only be considered a temporary fix.
  // TODO: Solve the core problem, which will probably entail something
  // similar to http://drupal.org/node/1876034.
  if (isset($metatags[$language])) {

But the issue wasn't with Workbench moderation. It was metatag that cannot save its own loaded data. If you do node_save(node_load($nid)); your metatags are broken with the current beta version. The beta version assumed your node was saved after a submit. The isset check solves this.

Dave Reid’s picture

Title: Change $entity->metatags object to match core data handling » Ensure $entity->metatags can be saved programmatically from a loaded entity only
Priority: Normal » Major
Issue tags: +D7 stable release blocker

The issue isn't we need to match core strucutre, because it isn't a field at all. The issue is just that we need to be consistent.

DamienMcKenna’s picture

Status: Active » Needs review
FileSize
809 bytes

In that case it should work fine as-is, so the comment just needs fixing.

Jax’s picture

Title: Change $entity->metatags object to match core data handling » Ensure $entity->metatags can be saved programmatically from a loaded entity only
Priority: Normal » Major
Status: Active » Reviewed & tested by the community
Issue tags: +D7 stable release blocker

Ok, that comment is more fair. :)

DamienMcKenna’s picture

Status: Reviewed & tested by the community » Needs work
DamienMcKenna’s picture

tests node_save()...

Ermahgerd, this is so berken. :-(

DamienMcKenna’s picture

DamienMcKenna’s picture

Could everyone please test the patch at #2020565 and let me know if that fixes the problem, at least for new nodes created after the patch is applied? FYI a key problem appears to be that the original language value may have been saved incorrectly. Argh.

DamienMcKenna’s picture

Status: Needs work » Fixed

After some testing I identified that #2020565: Records for nodes have the wrong language value during initial creation did indeed resolve the problem, so I've committed this message to explain that the problem wasn't because of Workbench Moderation.

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