I just tracked down this error and found that it is due to metatag_field_attach_view_alter() trying to load an entity that it doesn't have access to.

In my case, we allow access to term listing pages with terms controlled by Domain Taxonomy without concern about the particular domain restrictions, but then allow the normal Domain based restrictions everywhere else. We are doing this via a custom menu load callback on taxonomy/term/%.

If you want to support this, let me know and I can roll a patch. We are running a very old version of Metatags, but this code hasn't changed. Maybe something like this: (untested)

      // Reload the entity object from cache as it may have been altered by Panels.
      $token_type = token_get_entity_mapping('entity', $entity_type);
      $entities = entity_load($entity_type, array($entity_id));
      $options['token data'][$token_type] = $entities[$entity_id];
      $options['entity'] = $entities[$entity_id];

# to ...

      // Reload the entity object from cache as it may have been altered by Panels.
      $entities = entity_load($entity_type, array($entity_id));

      // Sanity check to ensure that entity_load() worked, this can fail.
      if ($entity = reset($entities)) {
        $token_type = token_get_entity_mapping('entity', $entity_type);

        $options['token data'][$token_type] = $entity;
        $options['entity'] = $entity;

        // Render the metatags and save to the cache.
        $output['metatags'] = metatag_metatags_view($instance, $metatags, $options);
        cache_set($cid, $output['metatags'], 'cache_metatag');
      }

Comments

DamienMcKenna’s picture

Status: Active » Postponed (maintainer needs more info)

Metatag hasn't had metatag_field_attach_view_alter() in months, please re-test with the current -dev release and let me know how it goes.

DamienMcKenna’s picture

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

As mentioned above, this function hasn't existed for several months, the problem shouldn't happen anymore.