Due to some temporary work-arounds for limitations in Panels and Views, it's possible that metatag_entity_view() may be triggered more than once during a page load. Add some logic so that it's only ran once.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

DamienMcKenna’s picture

Status: Active » Needs review
FileSize
681 bytes

This should do it.

DamienMcKenna’s picture

Status: Needs review » Fixed

Committed.

slayne40’s picture

Category: task » bug
Status: Fixed » Active

Hy,

I have a node with Entity Reference field.
During page load, the function metatag_entity_view is called once.
Problem on call : entity ID is not the node ID of the page but a referenced node ID... function end and the metatags are empty !

It is necessary that the function is called more than once.
If I delete the patch metatag work properly.

The solution may be to move the patch after the line :

// Only proceed if this entity object is the page being viewed.
  if (_metatag_entity_is_page($entity_type, $entity)) {

or maybe not ?

DamienMcKenna’s picture

Status: Active » Needs review
FileSize
896 bytes

How's about this?

DamienMcKenna’s picture

Status: Needs review » Fixed

Committed.

DamienMcKenna’s picture

Status: Fixed » Closed (fixed)

Now that Metatag v7.x-1.0-beta5 is out am closing this to keep the issue queue clean.

IRuslan’s picture

Issue summary: View changes

I'm still encounter that issue in last release version.
I'm using CTools, first call comes from ctools_node_content_render_node() plugin, which invoke full entity_view.
And second comes from metatag_ctools_render_alter().

And usage of $i_will_say_this_only_once does not help because metatag_entity_view() called second tiome with $force flag.
What's the reason to have that flag and use it in metatag_ctools_render_alter()?

Raphael Apard’s picture

Status: Closed (fixed) » Active

With a node with comment, _metatag_entity_is_page('comment', $comment) will return TRUE and $i_will_say_this_only_once will be set to true, and this will never triggered for node.

  • DamienMcKenna committed 150964f on 8.x-1.x
    Issue #1932192 by DamienMcKenna: Only run metatag_entity_view() once.
    
  • DamienMcKenna committed 31b13ab on 8.x-1.x
    Issue #1932192 by DamienMcKenna: Follow-up to ensure that the...