When Drupal calls the hook_entity_view() implementation in metatag.module, the language detection logic assumes that the $langcode is set correctly. This may not always be the case, and this patch changes the behaviour of the module in this case to use the detected language of the entity instead.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

achton’s picture

DamienMcKenna’s picture

DamienMcKenna’s picture

If the problem is with Panels / Panelizer displays, please test the latest -dev release and #2178411: Metatags not diplaying when node content is empty.

Failing that, please explain more detail behind the structure you are using for the node pages, including any modules being used to handle the display.

DamienMcKenna’s picture

Status: Needs review » Postponed (maintainer needs more info)
DamienMcKenna’s picture

Status: Postponed (maintainer needs more info) » Closed (duplicate)

This should be fixed in the latest -dev release, which will be the 1.0-rc1 release soon.

q11q11’s picture

It`s not fixed in 1.0, so have to make new patch, against 1.0.

DamienMcKenna’s picture

Status: Closed (duplicate) » Needs review
Parent issue: #2175021: META: Plan for Metatag 7.x-1.0-rc1 release »

Ok, fair enough, I'll review this when I get back from a mini vacation.

DamienMcKenna’s picture

Could you please confirm the problem still exists in the latest dev release? Thanks.

Status: Needs review » Needs work

The last submitted patch, 6: metatag-langcode-detection-2215517-6-D7.patch, failed testing.

jeffdiecks’s picture

Issue tags: +Needs reroll
mrjmd’s picture

Status: Needs work » Needs review
Issue tags: +SprintWeekend2015

I believe this issue is resolved. Current dev release has the following:

  // Determine the language this entity actually uses.
  $entity_language = metatag_entity_get_language($entity_type, $entity);

  // If no language was requested, try the language defined for this page
  // request.
  if (empty($langcode)) {
    $langcode = $GLOBALS['language_content']->language;
  }

  // This entity doesn't have any languages defined, i.e. it uses 'und'. This
  // can't conflict with loading the wrong language as entities either have no
  // language or they have specific one(s), they can't have both.
  if ($entity_language == LANGUAGE_NONE) {
    $langcode = LANGUAGE_NONE;
  }

  // If there are no meta tags for the currently identified language, and there
  // *are* meta tags defined for the entity's default language, use the entity's
  // default language's values, unless the "Don't load entity's default
  // language values if no languages match" option is enabled on the advanced
  // settings page.
  elseif (empty($entity->metatags[$langcode]) && !empty($entity->metatags[$entity_language]) && !variable_get('metatag_entity_no_lang_default', FALSE)) {
    $langcode = $entity_language;
  }

I don't currently have a multilingual setup so I'm hoping someone else can test and verify.

DamienMcKenna’s picture

Issue tags: -Needs reroll
DamienMcKenna’s picture

Status: Needs review » Postponed (maintainer needs more info)

Could someone please test the latest -dev snapshot and let me know if the problem persists?

DamienMcKenna’s picture

There have been a bunch of changes & improvements this year, can someone please check if the problem still persists with v1.7, or the current -dev release (but be careful because i18n support is currently broken)? Thanks.

DamienMcKenna’s picture

Status: Postponed (maintainer needs more info) » Closed (cannot reproduce)

We now have an extensive test suite and have not been able to reproduce this problem. If the problem persists with the latest dev release (or v1.8 due tomorrow) please reopen the issue and we'll see if we can work out what's causing the problem.