i've tried stable and latest dev versions of the modules

i have a field collection with a taxonomy term field, and when i want to display a full node using the field collection table view i get the following errors for each occurrence of the term field:
Notice: Undefined index: taxonomy_term in taxonomy_field_formatter_view() (string 1409 in /modules/taxonomy/taxonomy.module).
Notice: Trying to get property of non-object in taxonomy_field_formatter_view() (string 1409 in /modules/taxonomy/taxonomy.module).

the corresponding term fields are shown empty

when i switch to simple view everything is working like it should. in fact the table view also was working for me before, but after some update, i'm not sure which and where, it stopped working. i even reinstalled the whole drupal installation, and recreated the site anew to encounter the same error. maybe some update at the hosting server could cause it?

the hosting environment:
Drupal 7.7
PHP 5.2.17
mysql 5.1.56-log
Apache/2.2.19 (Unix) mod_ssl/2.2.19 OpenSSL/0.9.8e-fips-rhel5 mod_auth_passthrough/2.1 mod_bwlimited/1.4 FrontPage/5.0.2.2635

help me please

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

tim.plunkett’s picture

Priority: Major » Normal

Will attempt to debug and fix. Thanks for the bug report!

craigmc’s picture

Title: Load reference fields when building content. » undefined index with table view
Project: Entity API » Field Collection Table
Component: Code - misc » Code
Status: Needs review » Active

Also seeing this issue with taxonomy term fields in a field collection.
Tried all different settings for the term field display option (text, link, hidden) as hinted at in http://drupal.org/node/934726#comment-3924552 with no luck.

tim.plunkett’s picture

Project: Field Collection Table » Entity API
Component: Code » Code - misc
Status: Active » Needs review
FileSize
705 bytes

This might be me fundamentally misunderstanding the difference between Entity::buildContent() and Entity::view(), but the former is missing field_attach_prepare_view(), and this fixes the above issue with reference fields.

tim.plunkett’s picture

JustMagicMaria’s picture

Subscribing

srgk’s picture

what about the patch in #3? it looks inaccessible

zkday’s picture

can't views patch file in comment #3
This url is: http://drupal.org/files/issues/

tim.plunkett’s picture

Title: undefined index with table view » Load reference fields when building content.
FileSize
1.03 KB

Sorry about the delay, here's the patch again.

fago’s picture

hm, but now it's run twice, isn't it?

tim.plunkett’s picture

Field Collection Table is using buildContent in hook_field_formatter_view(). Should it not be?

I don't understand #9.

Remon’s picture

subs

j0rd’s picture

Title: undefined index with table view » Load reference fields when building content.
Project: Field Collection Table » Entity API
Component: Code » Code - misc
Status: Active » Needs review

I get a similar error on my site (both 7.7 and 7.8).

  • Notice: Undefined index: taxonomy_term in taxonomy_field_formatter_view() (line 1419 of /home/www/site.tld/htdocs/modules/taxonomy/taxonomy.module).
  • EntityMalformedException: Missing bundle property on entity of type taxonomy_term. in entity_extract_ids() (line 7389 of /home/www/site.tld/htdocs/includes/common.inc).

For me, it's very easy to duplicate. I have a node with the preview option enabled. If I preview, then preview again, I get the error I posted above.

Not exactly too sure what the problem is, but may be related. I'll test the patch when I get a second.

UPDATE: I just tested this patch against my problem and it did not resolve it.

--
Drupal Commerce Development & Themes

fago’s picture

Status: Needs review » Needs work

Well, field_attach_prepare_view is already invoked by entity_view(). However I found that:

// Build fields content.
// In case of a multiple view, node_view_multiple() already ran the
// 'prepare_view' step. An internal flag prevents the operation from running
// twice.
field_attach_prepare_view('node', array($node->nid => $node), $view_mode, $langcode);

So does that internal flag cover our situation too? If so, at least we also need to add a comment like that.

ygerasimov’s picture

Status: Needs work » Needs review
FileSize
1.41 KB

I got same problem when attaching entityreference field and use buildContent method to get the content.

It looks like internal flag doesn't cover our situation as field_attach_prepare_view() will invoke hooks anyway.

Shall we move field_attach_prepare_view() and entity_prepare_view() to buildContent() method completely as per attached patch?

fago’s picture

Status: Needs review » Needs work

From looking at the code I think it should cover our case too?

#14 is no real solution as it does away with multiple-preparing on view, what is important in case of having multiple view operation.

Thus, let's go with #8. But let's verify the flag to prevent it preparing twice works and add a comment to it as the one I quoted in #13.

tim.plunkett’s picture

Title: Load reference fields when building content. » Load reference fields when building content
Assigned: Unassigned » tim.plunkett

Will test and reroll.

Damien Tournoud’s picture

So, what's the difference between buildContent() and view() and why do we need both here?

Damien Tournoud’s picture

Rerolled #8. It is indeed the proper fix.

Damien Tournoud’s picture

Status: Needs work » Reviewed & tested by the community
fago’s picture

Status: Reviewed & tested by the community » Fixed

I verified it's indeed run only once. Thanks, committed.

Status: Fixed » Closed (fixed)

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

Anonymous’s picture

Issue summary: View changes

added info about the empty term fields