Preview button throws error when trying to preview after adding a new tag to a node.

How to reproduce this:
(1) Create content type with a taxonomy terms field
(2) Create a new node of the content type (1) /node/1/edit
(3) Add a taxonomy term to the relevant field
(4) Click on Preview button

Notice: Undefined index: taxonomy_term in taxonomy_field_formatter_view() (line 1443 of /***/taxonomy/taxonomy.module).
EntityMalformedException: Missing bundle property on entity of type taxonomy_term. in entity_extract_ids() (line 7501 of /***/includes/common.inc).

Drupal 7.12

Comments

bocaj’s picture

Status: Active » Postponed (maintainer needs more info)

Hey @refineo!

I followed your steps to reproduce this, but the preview works for me each time. I set taxonomies up to be free-tagging as well as a preset list and the preview option works both ways. I'm assuming that you are getting this issue after we resolved #1517864: Preview throws error The requested page "/node//edit" could not be found, is that correct?

Any other steps or information you could give me would be helpful since I'm not able to reproduce this issue.

Thanks!

Refineo’s picture

Yes, I am getting this issue on the same system after resolving the previous Preview issue.

Hmm... I will first try to reduce this issue scenario by disabling other contributed modules.
Until now I tested and I get these error messages with following modules and widget types (enabled and disabled):

Contributed Modules

Community Tags 7.x-1.x-dev
Drupal Wiki tagging suggestions (drupalwiki_tagging_suggest) 7.x-3.3
Hierarchical Select
Content Taxonomy Autocomplete
7.x-1.0-beta1+1-dev
Hierarchical Select Taxonomy Views 7.x-3.x-dev
Tagging (tagging) 7.x-3.3
Content Taxonomy 7.x-1.0-beta1+1-dev

Widget types:

Tagging module autocomplete javascript UI widget
Autocomplete term widget (tagging)
Select list
Hierarchical Select

I don't get these error messages only when selecting "None" (no tags) ,using for example Select list,
and then pressing the Preview button.

Refineo’s picture

Assigned: Unassigned » Refineo
Refineo’s picture

I debug the first notice message line 1443 of /***/modules/taxonomy/taxonomy.module :

the $display array:

... (Array, 5 elements)
label (String, 6 characters ) inline
module (String, 8 characters ) taxonomy
settings (Array, 0 elements)
type (String, 28 characters ) taxonomy_term_reference_link
weight (String, 1 characters ) 3

In taxonomy.module in $display for a taxonomy_term_reference_link my system throws the notice message because there is no expected $item['tid'] defined nor $item['taxonomy_term'] in the $display array.

Refineo’s picture

For the purpose of debugging this issue I commented out the line 7501 of common.inc causing the error message:

EntityMalformedException: Missing bundle property on entity of type taxonomy_term. in entity_extract_ids() (line 7501 of /***/includes/common.inc).

I get following messages instead but at least the Preview page shows up :)

Notice: Undefined index: taxonomy_term in taxonomy_field_formatter_view() (line 1443 of /***/modules/taxonomy/taxonomy.module).
Notice: Trying to get property of non-object in entity_extract_ids() (line 7503 of /***/includes/common.inc).
Notice: Trying to get property of non-object in taxonomy_term_uri() (line 147 of /***/modules/taxonomy/taxonomy.module).
Notice: Trying to get property of non-object in taxonomy_field_formatter_view() (line 1447 of /***/modules/taxonomy/taxonomy.module).
Notice: Undefined index: taxonomy_term in taxonomy_field_formatter_view() (line 1443 of /***/modules/taxonomy/taxonomy.module).
Notice: Trying to get property of non-object in entity_extract_ids() (line 7503 of /***/includes/common.inc).
Notice: Trying to get property of non-object in taxonomy_term_uri() (line 147 of /***/modules/taxonomy/taxonomy.module).
Notice: Trying to get property of non-object in taxonomy_field_formatter_view() (line 1447 of /***/modules/taxonomy/taxonomy.module).
Notice: Undefined index: taxonomy_term in taxonomy_field_formatter_view() (line 1443 of /***/modules/taxonomy/taxonomy.module).
Notice: Trying to get property of non-object in entity_extract_ids() (line 7503 of /***/includes/common.inc).
Notice: Trying to get property of non-object in taxonomy_term_uri() (line 147 of /***/modules/taxonomy/taxonomy.module).
Notice: Trying to get property of non-object in taxonomy_field_formatter_view() (line 1447 of /***/modules/taxonomy/taxonomy.module).

Note: I got these notices 3 times because I had 3 tags in my node.

When I test a node with 1 tag assigned I get these notices only once:

Notice: Undefined index: taxonomy_term in taxonomy_field_formatter_view() (line 1443 of /***/modules/taxonomy/taxonomy.module).
Notice: Trying to get property of non-object in entity_extract_ids() (line 7503 of /***/includes/common.inc).
Notice: Trying to get property of non-object in taxonomy_term_uri() (line 147 of /***/modules/taxonomy/taxonomy.module).
Notice: Trying to get property of non-object in taxonomy_field_formatter_view() (line 1447 of /***/modules/taxonomy/taxonomy.module).

The missing bundle property exception is thrown when there is no $entity->{$info['entity keys']['bundle']} set (or there is no value in the bundle key at all).

I debugged dpm($info['entity keys']['bundle']) and in my case it is the missing bundle: 'vocabulary_machine_name'.

Then I found a D8 core issue that is potentially related here: #1054162: Taxonomy bundles not supported by EntityFieldQuery (followup).
This requires further investigation.

Refineo’s picture

Assigned: Refineo » Unassigned
Status: Postponed (maintainer needs more info) » Active

@bocaj , I would suggest to move this issue to Drupal Core 7.x for further investigation as I cannot find any root cause within the Content Type: Extras module.

Note to myself: here are (potentially related issues worth to investigate:
#1054162: Taxonomy bundles not supported by EntityFieldQuery (followup)
#938462: Fix EntityFieldQuery fatal error in certain cases and document bundle limitations
#1281114: Database records not deleted for Term Reference Fields after Term is Deleted

Refineo’s picture

Here are all contributed modules I used in this system
where I can find references to EntityFieldQuery (grep -r EntityFieldQuery) :

og
location_feeds
field_collection
entity_translation
entitycache
xmlsitemap
field_validation
entityreference
entity
media
cnr
migrate
maestro

I will now try to disable them one by one to find the module causing the issue.

Refineo’s picture

Contributed modules I used in the systme where I can find references to EntityFieldQuery (grep -r EntityFieldQuery) :
I disabled each module , cleared all cache and tested the Preview mode:


module module status test result after clearing cache
og disabled ERROR
location_feeds disabled ERROR
field_collection disabled ERROR
entity_translation disabled ERROR
entitycache disabled ERROR
xmlsitemap disabled ERROR
field_validation disabled ERROR
entityreference disabled ERROR
media disabled ERROR
cnr (corresponding node references) disabled ERROR
migrate disabled ERROR
maestro disabled ERROR
entity (Entity API) enabled ERROR

I didn't disable Entity API until now as it has many dependencies.
For the moment I would assume the issue is either in Entity API or in Drupal Core.

Refineo’s picture

Project: Content Type: Extras » Entity API
Component: Code » Entity property wrapper

I retested with the latest Entity API 7.x-1.0-rc1+46-dev and the error persists:

Steps to reproduce:

1. Install Entity API, Content Type Extras
2. Add custom content type with:
- Preview mode enabled
- Taxonomy term field
3. Create a new node of the custom content type and save without taxonomy terms added
4. Edit the node (I used node/1/edit) and add a taxonomy term to the relevant field
5. Click on Preview button.

In my setup the following error message appears:

Notice: Undefined index: taxonomy_term in taxonomy_field_formatter_view() (line 1443 of /***/modules/taxonomy/taxonomy.module).
EntityMalformedException: Missing bundle property on entity of type taxonomy_term. in entity_extract_ids() (line 7501 of /***/includes/common.inc).

Environment

Drupal 7.12

I reassign this to Entity API issue queue as I found issues related to EntityMalformedException there.
Maybe you can help to solve this issue ? Thanks for any feedback!

Refineo’s picture

Hmm... I tested again on a fresh D7.12 install and I don't experience this issue.
I need to find out what is the issue cause anyway.

Refineo’s picture

Assigned: Unassigned » Refineo

On the system affected I created a completely new test dataset:
ZZ_Issue_1526298_Content_Type (includes terms reference)
ZZ_Issue_1526298_Node
and I cannot reproduce the issue there.

It seems the cause for the issue is in my content type set up.
I cannot reproduce this issue for any other content type.

The affected content type has following fields:

Title	title	Node module element		
Language	  language	Language selection		
Tags  field_tags	Term reference	Select list	
Body  body	Long text and summary	Text area with a summary	
Date date  field_date	Date	Pop-up calendar	
Reference  field_reference	Node reference	Reference from URL
URL redirects  redirect	Redirect module form elements		
URL path settings  path	Path module form elements
Refineo’s picture

Assigned: Refineo » Unassigned
Status: Active » Needs review

OK I temporarly solved this issue by deleting the field from the content type and adding the same field once again.
I could do this because I was on development environment.
However I still don't know how I would handle this if it occured on production system.

One thing I didn't think about is that the content type was migrated from another website using Features module.
I will further investigate if the content type migration could be the reason.

fago’s picture

Project: Entity API » Content Type: Extras
Component: Entity property wrapper » Code
Status: Needs review » Active

EntityMalformedException: Missing bundle property on entity of type taxonomy_term. in entity_extract_ids() (line 7501 of /***/includes/common.inc).

This exception is part of core, not the entity api module. Anyway, it's mostly thrown because of invalid entities being passed around. Also, I see no patch here.

omaster’s picture

Any update on this?

Refineo’s picture

Status: Active » Closed (cannot reproduce)

I suggest to close this issue as I cannot reproduce the error anymore.
Feel free to reopen if the error still exists and you can provide steps to reproduce it.

pacufist’s picture

I faced this issue while was trying to create taxonomy term using Autocomplete term widget (tagging).

Drupal 7.18

I think we should set propertie $type somewhere in the function: taxonomy_term_save()

Because now it`s doesn`t exists.

Object $term info:

$term	stdClass		
vid	string	"1"	
name	string	"grid"	
vocabulary_machine_name	string	"keywords"	
translations	stdClass		
name_field	array[1]		
tid	string	"59"	
weight	integer	0	
parent	array[1]		

But in function entity_extract_ids() system requires type of entity.

pacufist’s picture

Status: Closed (cannot reproduce) » Active

Sorry, it`s issue not about Content Type: Extras module.

It`s but in Content Type: entity_translation_language language.

pacufist’s picture

Status: Active » Closed (cannot reproduce)