I have a problem where metatags are generated for a draft and when the draft is published the metatags for the published content are not refreshed and show draft data until the cache is next cleared.
This is my problem in more detail:
- An existing node has correct meta tags.
- Edit an existing node and save in draft state and I end up on the draft page where the metatags are for the draft.
- I refresh the published node view page now and it still ahs the correct metatag values.
- I publish the new draft and end up on the published node view page viewing the new version. Now the metatags are wrong, they are still the metatags from step 2. For example the canonical link is http://example.com/node/294/draft
- I refresh the node view page and the metatags are still wrong.
- I clear the cache and the metatags are correct again.
#2199533: Token replacement not updating for workbench drafts seemed like a similar issue but I don't fully understand the explanation of that problem and the patch didn't fix my issue.
Also I'm not sure if the component of this issue is correct or not as I'm not sure what the root of the problem is.
I'm using Workbench 7.x-1.2 and Workbench moderation 7.x-1.4.
Comments
Comment #1
damienmckennaOdd. I wonder would #2420489: Restructure entity caching so it can be cleared more easily help?
Clearly, though, it needs to hook into WM and clear the cache on a state change.
Comment #2
damienmckennaJust to confirm it - what version of Workbench Moderation are you using?
Comment #3
damienmckennaComment #4
rooby commentedYour proposed solution in #1 sounds like it would work.
I'm using Workbench 7.x-1.2 and Workbench moderation 7.x-1.4.
Comment #5
justindodge commentedHey guys, here's a solution as a custom module hook - a temporary workaround for me that takes the approach
of #1.
I could easily roll this into a patch for Metatag, but I wonder if anyone has any input regarding the
cache key being used to wipe cache entries - I'm not intimately familiar with all of the components
of the cid used in cache_metatag. This code seems appropriate to me, but maybe there's a way some keys
are built that makes this either too heavy handed or perhaps misses a scenario.
Comment #6
damienmckennaYou should use:
Comment #7
rooby commentedDoes that output cache issue you just committed help this or is that different?
Comment #8
damienmckennaThe other cache thingy is something else, though disabling the output cache would cover up this issue.
Comment #9
damienmckennaNot going to do this for 1.5.
Comment #10
damienmckennaDoes this fix the problem?
Comment #11
damienmckennaComment #12
beeradb commentedThis patch was posted during the time I wrote a nearly identical version. Interesting timing :)
I applied and tested this patch to a 1.4 installation of metatag and it works as intended.
Comment #13
damienmckenna@beeradb: Thanks for the review!
Committed.