I just updated from 7.x.1.2 to 7.x.1.4 and began getting the following notice on every page on the user site (which uses a custom theme based on tb_university):

Notice: Undefined index: #markup in __lambda_func() (line 6 of .../sites/all/modules/views_php/plugins/views/views_php_handler_field.inc(202) : runtime-created function)

Regressing to 7.x.1.3 doesn't fix it, but regressing to 7.x.1.2 does. Core and all other modules are current on the site.

Anyone have an idea of what would cause this or how to fix it in the current version? I'm not seeing any indications of errors in the admin interface on views that use views_php, and the error log merely records the same notice as above.

Subsequent note: I just changed this from bug to support since I found that the same combination of upgrading to core 7.56 and entity reference 7.x.1.4 in a different site didn't trigger the same problem. There must be some interaction occurring in the first site that I'm not understanding.

Comments

brpubs created an issue. See original summary.

brpubs’s picture

Category: Bug report » Support request
Issue summary: View changes
cudevdev’s picture

Between 1.2 and 1.4, Entity Reference changed it's implementation of `hook_field_formatter_view()`. Instead of simply providing markup:

$result[$delta] = array('#markup' => l($label, $uri['path'], $uri['options']));

it uses a theme hook. It now implements hook_theme() and provides a new function theme_entityreference_label(), which is called by the theme layer.

In short, there's a warning because $item['#markup'] no longer exists in items created by Entity Reference.

In my case, this was resolved by changing a template file which changed $item['#markup']. I'm guessing your view has some PHP which does the same thing.

I was just adding some text to the link, so $item['#label'] .= " EXTRA TEXT"; did the trick.

brpubs’s picture

Thanks SO much -- sorry it took me so long to get back to this. My issue wasn't solved quite the same way as yours, but you pointed me in the right direction. In my case, I'd been drilling down to get the title of a publication that was a field linked by entity reference, which had previously been reachable with $publication_source = $data->field_field_publication_source[0]['rendered']['#markup'] -- that became $publication_source = $data->field_field_publication_source[0]['rendered']['entity']->title.

pureh2o’s picture

Hi,

It took me so much time to realize that it was this change here that was triggering the same error... I'm an average/beginner when it comes to drupal.

I had custom links next to the label added with the markup, thus not only one links but many links for all the languages, since my entities are translated in all the languages. Thus it's easier to access the translations directly. And in case there was a missing translation I would add a link to add the missing translation of that entity.

I found the issue in the label theme function, but I had to use the same solution as yourselves to use the label field. And since the label field is rendered plain text I had to remove the function that was checking the plain text at line 1465. ( $output .= check_plain($label);)

I had to modify the code of the entity_reference which I would like to avoid. Is there another solution to this? so that I do not need to modify the entityreference module code? Can I add something else or use something else in my module? other than markup that is not working anymore.
Unfortunately your idea with the link on the entity is great but it's only to the main entity and I need it to the translated related nodes as well.

Thank you