Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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
Comment | File | Size | Author |
---|---|---|---|
#9 | metatag-n1871020-9.patch | 800 bytes | DamienMcKenna |
Comments
Comment #1
protools CreditAttribution: protools commentedsame problem: override title for front page, but title tag set to default ore empty if not set on global settings
Comment #2
dshumaker CreditAttribution: dshumaker commentedI'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.
Comment #3
dshumaker CreditAttribution: dshumaker commentedI found a fix. Add these three lines to metatag.module on line 404
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.
Comment #4
DamienMcKennaCould you please test the patch in #1845326: Metatags not loading correctly with beta4, it may be the same core problem.
Comment #5
dshumaker CreditAttribution: dshumaker commentedI did try the January 7th patch and that didn't help.
Comment #6
hugov CreditAttribution: hugov commentedI 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.
Comment #7
DamienMcKennaOh. Ok. Yeah, I was able to reproduce this problem. Damn.
Comment #8
DamienMcKennaSo 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.
Comment #9
DamienMcKennaThis 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.
Comment #10
DamienMcKennaI've committed this.
Comment #12
DamienMcKennaFYI 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