I have create a new page and modify some meta tags

But all modified tags reset back to default after publish/unpublish from admin/content

Though it works fine if I check/uncheck Publishing Options from node/1/edit

CommentFileSizeAuthor
#9 metatag-n1871020-9.patch800 bytesDamienMcKenna
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

protools’s picture

same problem: override title for front page, but title tag set to default ore empty if not set on global settings

dshumaker’s picture

I'm experiencing the same thing. I am using the workbench module and I have three node status' (Draft, Needs Review, and Published). If I save a node in the draft status then the meta tags appear not to be saved. However when I look at the database the meta tags are saved (ie serialized in the metatag table) but are wrapped in two levels of "und" (for undecided language (Language neutral). Those two levels of parent arrays seem to mess up the loading of the metatags. Furthermore when I write a script to strip out those two levels of "und" then the meta tags are loaded fine.

HOWEVER, when I create a new node and fill in some meta tag information and before saving change it's published status to published, then the meta tags are retained, saved and loaded correctly. So that's great that I found a work around (ie skipping the draft and needs review stages) but very bad for clients that need the functionality of the workflows provided by the workbench module.

So I either tell my client this funky work around or I try to write a hook_save() that strips out those extra "und" arrays before saving a node. Neither options are very appealing.

Help much appreciated.

dshumaker’s picture

I found a fix. Add these three lines to metatag.module on line 404

    if (array_key_exists($language, $metatags)) {
      $metatags = $metatags[$language];
    }

Now granted, that is probably not the best way to do it, but its working for me. I'll submit a patch if anyone is interested.

DamienMcKenna’s picture

Could you please test the patch in #1845326: Metatags not loading correctly with beta4, it may be the same core problem.

dshumaker’s picture

I did try the January 7th patch and that didn't help.

hugov’s picture

I Have the same problem on an hotel website. The site is in english, french and spanish. I can confirm. #3 seem to solve the problem. The January 7th patch do not solve the problem.

DamienMcKenna’s picture

Title: All modified tags reset back to default after publish/unpublish » Conflict with Workbench Moderation: tags revert to defaults after moderation change

Oh. Ok. Yeah, I was able to reproduce this problem. Damn.

DamienMcKenna’s picture

So I ran through a few tests, and I can confirm that if you change the moderation status via the node/[nid]/edit page then everything is fine. However, when changes are made from the node/[nid]/moderation tab the data is saved incorrectly.

DamienMcKenna’s picture

Status: Active » Needs review
FileSize
800 bytes

This ought to resolve the problem, it's a variation on the code posted by dshumaker in #3 and includes a comment explaining what's going on.

DamienMcKenna’s picture

Status: Needs review » Fixed

I've committed this.

Status: Fixed » Closed (fixed)

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

DamienMcKenna’s picture

FYI I've added a follow-on issue to add an update script to fix any existing data that was corrupted by this: #1919070: Fix any meta tags that may have been serialized twice