Closed (fixed)
Project:
Metatag
Version:
7.x-1.x-dev
Component:
Multilingual/intl
Priority:
Major
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
21 Jun 2013 at 18:38 UTC
Updated:
12 Jul 2014 at 05:10 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
damienmckennaWhat display mechanism are you using for the nodes - Panels, normal page templates, Display Suite, etc?
Comment #2
moonray commentedThe attached patch provides the global langcode by default if none is provided. This way the caching cid is correct.
Comment #4
moonray commentedSame patch with fixed paths.
Comment #5
moonray commentedTrying again.
Comment #6
damienmckennaIf the current entity doesn't support language assignment, or it's disabled, Metatag uses LANGUAGE_NONE instead of $GLOBALS['language_content']->language, so I don't think this is the best direction.
Also, please clarify what system is being used to display the entity as the $langcode value shouldn't be empty.
Comment #7
moonray commentedmetatag itself calls the metatag_entity_view() function with the langcode being NULL in 3 instances. These are the cause of the problem.
In my particular case the call from metatag_ctools_render_alter() was the cause of the issue.
The reason I decided to use $GLOBALS['language_content']->language is https://api.drupal.org/api/drupal/modules%21node%21node.module/function/...
EDIT: Also see https://api.drupal.org/api/drupal/includes%21bootstrap.inc/function/drup... (which ensures $GLOBALS['language_content'] is always set)
Comment #8
damienmckennaYes, I'm aware of the different reasons to use $GLOBALS['language_content'], however the $langcode value is different in hook_entity_view depending on different scenarios. The reason you're seeing an empty $langcode is because you're displaying the page with Panels, which doesn't work correctly with multiple languages as opposed to normal page displays, so any changes should go into metatag_ctools_render_alter().
Comment #9
moonray commentedWhat about metatag_views_post_render() and metatag_taxonomy_term_view_alter()?
I'm not running through either of those function in my use case. Should those also include the settings of default value for $langcode? (I'd like to provide a full patch).
Comment #10
David_Rothstein commentedI ran into this but honestly couldn't figure out how to determine the correct language to pass in for all cases.
I needed something that worked, and if the goal is just to bust the cache when necessary without affecting how the rest of the function uses the $langcode variable, here is one kind-of-hacky way to do it.
Patch applies against the beta7 release, but not against the latest dev code.
Comment #11
David_Rothstein commentedSame patch, better filename.
Comment #12
damienmckennaCould someone please test the latest dev version?
Comment #13
damienmckennaComment #14
hefox commentedPatch is being used on a project with multiple testers/developers and has not presented any problems yet and has fixed the issue.
Only tested with beta :/
Comment #15
hefox commentedbeta9 version of beta7
Comment #16
damienmckennaThis adds an update script to clear the caches.
Comment #17
damienmckennaComment #18
damienmckennaCommitted. Thanks everyone!