Using Peekaboo 7.x-2.0-beta1 with both References 7.x-2.0 and 7.x-2.x-dev (2012-Jan-06).

Trying to view a node where there is a node_reference field with a node being referenced, I get the following error:

EntityMalformedException: Missing bundle property on entity of type node. in entity_extract_ids() (line 7410 of includes/common.inc).

If there is no content in the field, the error does not occur.

Also, if the same value is exposed through Views actively using Peekaboo, Peekaboo seems to function as expected.

I'm not entirely sure whether this issue is being caused by Peekaboo, as the Field Formatter options for the Node Reference field within Node Display can be set to either `Peekaboo: Disabled` OR `Peekaboo: Enabled` and the error still occurs. If I set the display formatter to either `Node ID` or `Hidden` the error does not occur.

Running `debug_backtrace()` immediately before the error in `common.inc` reveals that the code is passing through `peekaboo_field_formatter_view()` regardless.

Comments

carn1x’s picture

Status: Active » Closed (works as designed)

After digging through the code a bit more I realize that Peekaboo is very unlikely responsible.

arkz’s picture

After installing Peekaboo 7.x-2.0-beta1, I'm receiving similar errors (without even enabling it for any fields). The errors go away when I disable Peekaboo, so I guess this module is causing it, or perhaps another module not playing nicely with it.

Notice: Undefined index: taxonomy_term in taxonomy_field_formatter_view() (line 1435 of C:\xampp\htdocs\drupaltest\modules\taxonomy\taxonomy.module)

Notice: Trying to get property of non-object in taxonomy_field_formatter_view() (line 1449 of C:\xampp\htdocs\drupaltest\modules\taxonomy\taxonomy.module)

EntityMalformedException: Missing bundle property on entity of type taxonomy_term. in entity_extract_ids() (line 7405 of C:\xampp\htdocs\drupaltest\includes\common.inc).

From my limited digging it looks like it's stemming from line 287 in peekaboo.module:
return module_invoke($display['settings']['peekaboo_module'], 'field_formatter_view', $entity_type, $entity, $field, $instance, $langcode, $items, $display);

but I don't know enough about Drupal to know what the problem is. Hopefully this will help.

arkz’s picture

Status: Closed (works as designed) » Active
danielb’s picture

Did you try clearing your cache under 'performance' ?

I wonder if we need to implement hook_formatter_prepare_view()

danielb’s picture

Status: Active » Fixed

Yeah that's what it was, I've added that function. Not sure I did it perfectly cos it's kind of an awkward hook.

arkz’s picture

Status: Fixed » Active

Unfortunately it doesn't seem to have solved the problem, and added a new error as well.
Warning: Parameter 6 to taxonomy_field_formatter_prepare_view() expected to be a reference, value given in call_user_func_array() (line 794 of C:\xampp\htdocs\drupaltest\includes\module.inc)

I'm sure you understand the issue better than me but I'll write what I've found in case it helps:

I only get the error on taxonomy reference fields, and it seems to be because the $items array is only passing through the tid value for each item, whereas the taxonomy_field_formatter_view function expects a taxonomy_term aswell.

As a quick hack, the following code (entered just above the module_invoke call on line 287), as well as removing the formatter_prepare_view hook, fixes the issue for me.

    if($display['settings']['peekaboo_module'] == "taxonomy") {
      foreach ($items as $delta => $item) {
        $items[$delta]['taxonomy_term'] = taxonomy_term_load($item['tid']);
      }
    }

But unfortunately I wouldn't know where to begin on fixing the underlying problem.

By the way, is it just me getting this issue? I'm starting to think my bloated development environment may be causing problems, as I'm now getting a _form_validate() error upon enabling Peekaboo for a field. Guess I'll try it on a cleaner install when I get time.

danielb’s picture

Clear your cache ?

Nah that wouldn't be it, since it sounds like the hook executes for you.

How come it worked fine for me, then?

danielb’s picture

Try this

change this function

<?php
/**
 * Implements hook_field_formatter_prepare_view().
 */
function peekaboo_field_formatter_prepare_view($entity_type, $entities, $field, $instances, $langcode, &$items, $displays) {
  return module_invoke($field['module'], 'field_formatter_prepare_view', $entity_type, $entities, $field, $instances, $langcode, $items, $displays);
}
?>

to this:

<?php
/**
 * Implements hook_field_formatter_prepare_view().
 */
function peekaboo_field_formatter_prepare_view($entity_type, $entities, $field, $instances, $langcode, &$items, $displays) {
  $function = $field['module'] . '_field_formatter_prepare_view';
  if (function_exists($function)) {
    return $function($entity_type, $entities, $field, $instances, $langcode, $items, $displays);
  }
}
?>

The awkward thing I mentioned before is that getting the module's name from $field['module'] is inconsistent with the rest of the peekaboo module which gets the module name from the display settings. But this function acts on multiple entities and stuff, so umm.. what :(

arkz’s picture

Status: Active » Reviewed & tested by the community

That did the trick. Excellent - thanks! Great module by the way :)

danielb’s picture

Ah ok yeah the reason was that module_invoke() sucks balls.

danielb’s picture

Status: Reviewed & tested by the community » Fixed
carn1x’s picture

awesome thanks :D

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.