Glad I found this module, saved me a mess of css :-)

I have terms and nodes. At some point, I assigned tid=10 to nid=5 (for example). Later, I deleted tid=10 from the vocabulary.

Next, I installed taxonomy_formatter and it worked great until I hit a view showing nid=5 where I got these errors:

Notice: Undefined index: 10 in taxonomy_formatter_field_formatter_view() (line 151 of /var/aegir/platforms/commerce_kickstart-1.3/sites/all/modules/taxonomy_formatter/taxonomy_formatter.module).
EntityMalformedException: Missing bundle property on entity of type taxonomy_term. in entity_extract_ids() (line 7501 of /var/aegir/platforms/commerce_kickstart-1.3/includes/common.inc).

Instead of digging in the code, I just fixed my problem with this SQL:

delete from field_data_field_tags where field_tags_tid = 10;

Don't try the fix just mentionned - it worked on my data, it won't work on yours!

I presume the bug lies deeper in the Fields API, but I wanted to note it here since it's the first time I encountered the problem. Found it: #1075998: Notice: Undefined index: taxonomy_term after re-using term reference fields

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Robin Millette’s picture

Issue summary: View changes

Updated issue summary.

mh86’s picture

Status: Active » Needs review
FileSize
1.15 KB

I had the same problem on my website and the attached patch makes the code in the formatter more robust.

azinck’s picture

Can confirm the patch in #1 has fixed it for me. Thanks!

Robin Millette’s picture

Version: 7.x-1.3 » 7.x-1.x-dev
Status: Needs review » Reviewed & tested by the community
FileSize
890 bytes

That works, but I prefer the shorter

if (!isset($actterm[$termid])) continue;

option. I've provided a patch as well. They are functionnally equivalent.

mh86’s picture

I don't think that conforms to the Drupal coding standards and in my opinion the other one is easier to understand.

Robin Millette’s picture

You're right. Without braces, my patch doesn't confirm to our coding standards. I alyways forget those for single line code-blocks.

As for easier to unsterstand, I generally prefer to keep level nesting smaller but that's not something to debate here :-)

dkingofpa’s picture

Could we get this committed please?

dkingofpa’s picture

Status: Reviewed & tested by the community » Closed (duplicate)

It appears this is a duplicate of #934726: Undefined index: taxonomy_term in taxonomy_field_formatter_view(). The patch listed in #1 was applied for that issue. http://drupalcode.org/project/taxonomy_formatter.git/commit/64e6ec7d9824...

Fix is available in 7.x-1.4

dkingofpa’s picture

Issue summary: View changes

Updated issue summary.