EntityMalformedException: Missing bundle property on entity of type node. in entity_extract_ids() (line 7390

I started getting this error after updating to 7.8 when I try and add a node type I have called "status". Other types have no problem.

In common.inc I output the $entity object on the error page and it contains

stdClass Object
(
    [field_status] => Array
        (
            [und] => Array
                (
                    [0] => Array
                        (
                            [tid] => 28
                        )

                )

        )

)

The "field_status" is a "Term reference" field. I use other Term reference fields on other content types with no problem.

I have no nodes in the {nodes} database table with a blank type.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

markosaurus’s picture

Yup, exactly the same happened to me, I've been searching for an answer for weeks now without getting anywhere, this project was almost complete and then bang, this happens. I'll post back if I find anything.

BTW - this is also an issue for people with type "file" and "field" that I have see so far.

Canadaka’s picture

I can't figure out why this happens on just this content type. I have 16 content types on my site and all the others work fine. This problem type is also the most simple with 4 fields, 3 of which are reused.

Node reference (existing)
Node reference (existing)
List (integer)
Term reference (existing)

I looking in the database at the node_type and tables for each of the fields above, there is nothing abnormal about them compared to other working content types.

I even tried deleting the "field_status" mentioned above and cleared all caches. and its still mentioned in the backtrace, even though its deleted

[message:protected] => Missing bundle property on entity of type node.
                            [string:Exception:private] => 
                            [code:protected] => 0
                            [file:protected] => D:\Hosted Sites\trailforks.com\www\includes\common.inc
                            [line:protected] => 7390
                            [trace:Exception:private] => Array
                                (
                                    [0] => Array
                                        (
                                            [file] => D:\Hosted Sites\trailforks.com\www\modules\field\field.attach.inc
                                            [line] => 182
                                            [function] => entity_extract_ids
                                            [args] => Array
                                                (
                                                    [0] => node
                                                    [1] => stdClass Object
                                                        (
                                                            [field_status] => Array
                                                                (
                                                                    [und] => Array
                                                                        (
                                                                            [0] => Array
                                                                                (
                                                                                    [tid] => 
                                                                                )

                                                                        )

                                                                )

                                                        )

                                                )

                                        )

I even deleted all fields and I still get this error and output.

I then deleted the content type and all nodes of that type, cleared caches, checked database for any lingering data, manualy cleared cache tables, restarted web server and memcache. I then created the content type again from scratch using the same name, and I still get the error! *pulls out hair*

So I deleted that content type again and re-created using a different machine name and now there are no errors. I'm lucky in that this is a new site and I only had a few nodes created with that type. If others having this error have many nodes.. good luck!

Canadaka’s picture

well I feel dumb now, turns out the problem was caused by some of my custom code, I somehow deleted the $nid variable in the node_load() function, it was there before because I had tested it previously.

       if ($node->type == 'report') {
		$tid = $node->field_status['und'][0]['tid'];		
		$nid = $node->field_associated['und'][0]['nid'];
		$update = node_load();                                                <---- $nid should be here
		$update->field_status['und'][0]['tid'] = $tid;
		node_save($update);
	}

So @markosaurus check to make sure you don't have any custom code in your custom modules, my problem wasn't actually a drupal bug.

markosaurus’s picture

I do have a custom module which I use to modify the contact form, but I already disabled that in-case that was the culprit.

Incidentally I also get this when I try to use access the "views" module in the admin interface...which is strange and tells me there is something else going on here.

I tried taking out all of my custom templates, turning off all custom modules, cleared cache, still no joy.

Any other ideas?

Dave Sandilands’s picture

I have this same error in Views, apart from the line no. being 7389
I created an attachment view that contains a couple of custom fields, business_name and value
This worked fine but I wanted a total for one of the fields ie value
The view is grouped on business_name.
I set aggregation to on and immediately got the error.
Now I can't edit the view at all!

Afraid I don't have any idea on what's happened much less a solution.

[Later] This doesn't appear to be a Views bug as it also appears in http://drupal.org/node/1281974
which is about field collections

Gold’s picture

Just a little more data for those working on this;
We came across this issue by hitting admin/content and sorting on any field.

Our content consists of 2 content types. Page and redirect.

Page is out of the box + 2 term references.

redirect has the body removed, a node reference using field_redirection to present a 302 http header via the formatter.

We don't have the time to explore this but I wanted to add this info incase it helped out.

coderintherye’s picture

Status: Active » Closed (works as designed)

Here is what changed between 7.7 and 7.8 that causes this issue. Previously, Drupal core was working around this error, now it is explicitly being told to fail when it hits this condition. However, this is not actually a bug, this is as designed, as noted in the current 7.8 release notes. Regardless of how you feel about that change, if you are experiencing this problem, it is most likely from a contrib module, most likely Media (though in my case it was wordpress_migrate). You can try disabling your enabled contributed modules one-by-one until you find which one is causing the problem then go see if that module has an update to fix the issue.

Here is what I found Angie to have said on the issue, the first is on the release page for 7.8:

"Due to stricter error handling in Drupal 7.8 around entities, users of the Media module are experiencing EntityMalformedException errors. A workaround is posted at http://drupal.org/node/1266620#comment-4941950 and engineers are actively working on a new release."

as well as at http://drupal.org/node/1067750#comment-4943844

"Yeah... I'd have to agree. While I'm really sorry for breaking APIs suddenly by inadvertently making this check more strict than it was in 7.7 and below, it sounds like Media module is relying on a weird bit of undocumented magic here for its purposes. I think it would be better from both a future maintainability and DX perspective for the module to be explicit about the behaviour that it's intending in this case (so code to directly turn off field-ability if it hits this case), and to follow conventions already established by other entities."

@@ -7371,12 +7378,24 @@
  */
 function entity_extract_ids($entity_type, $entity) {
   $info = entity_get_info($entity_type);
+
   // Objects being created might not have id/vid yet.
   $id = isset($entity->{$info['entity keys']['id']}) ? $entity->{$info['entity keys']['id']} : NULL;
   $vid = ($info['entity keys']['revision'] && isset($entity->{$info['entity keys']['revision']})) ? $entity->{$info['entity keys']['revision']} : NULL;
-  // If no bundle key provided, then we assume a single bundle, named after the
-  // entity type.
-  $bundle = $info['entity keys']['bundle'] ? $entity->{$info['entity keys']['bundle']} : $entity_type;
+
+  if (!empty($info['entity keys']['bundle'])) {
+    // Explicitly fail for malformed entities missing the bundle property.
+    if (!isset($entity->{$info['entity keys']['bundle']}) || $entity->{$info['entity keys']['bundle']} === '') {
+      throw new EntityMalformedException(t('Missing bundle property on entity of type @entity_type.', array('@entity_type' => $entity_type)));
+    }
+    $bundle = $entity->{$info['entity keys']['bundle']};
+  }
+  else {
+    // The entity type provides no bundle key: assume a single bundle, named
+    // after the entity type.
+    $bundle = $entity_type;
+  }
+
   return array($id, $vid, $bundle);
 }

For more information see:
#1067750: Let Field API fail in a tale-telling way on invalid $entity
#1164852: Inconsistencies in field language handling

coderintherye’s picture

Also to note, if you do want to hack core to *temporarily* get around the issue, you should be able to remove

 || $entity->{$info['entity keys']['bundle']} === '')

in most cases, and you will be back to normal, so that line in common.inc turns into

if (!isset($entity->{$info['entity keys']['bundle']})) {

Or you could revert your common.inc to the code from 7.7.

markosaurus’s picture

Reverting common.inc back without reverting the rest of the codebase is just asking for trouble surely?

And as for removing that explicit fail check, I tried that and it didn't make any difference...hmmm.

coderintherye’s picture

If you look at the diff, you'll see there is no harm to reverting common.inc, you can even use the pasted code above in a patch with -R, but yes in general hacking core is the worst of all options.

On a side note, you could also try reaching into the database and doing a "SELECT * FROM node where type='';" if you have > 0 results for that query, then should fix those nodes to have a type.

The key point here is that the problem is likely arising from contrib module code and you should attempt to determine what module is the problem.

markosaurus’s picture

OK, thanks for all the help so far, this is so frustrating to try and fix!

I've had to start and get more ruthless with it as I can't really aford this time to fix the issue (which shouldn't have arisen in the first place IMO!) and I'm sure nobody else can either.

I moved to common.inc v7.7 and now I get this;

* Notice: Trying to get property of non-object in entity_extract_ids() (line 7379 of /home/dixon/public_html/dev/includes/common.inc).
* Notice: Undefined index: field_name in field_language() (line 275 of /home/dixon/public_html/dev/modules/field/field.multilingual.inc).
* Notice: Undefined index: field_name in field_language() (line 275 of /home/dixon/public_html/dev/modules/field/field.multilingual.inc).
* Notice: Undefined index: field_name in field_language() (line 275 of /home/dixon/public_html/dev/modules/field/field.multilingual.inc).
* Notice: Undefined index: field_name in field_language() (line 275 of /home/dixon/public_html/dev/modules/field/field.multilingual.inc).
* Notice: Undefined index: field_name in field_language() (line 275 of /home/dixon/public_html/dev/modules/field/field.multilingual.inc).
* Notice: Undefined index: field_name in field_language() (line 275 of /home/dixon/public_html/dev/modules/field/field.multilingual.inc).
* Notice: Undefined index: field_name in field_language() (line 275 of /home/dixon/public_html/dev/modules/field/field.multilingual.inc).
* Notice: Undefined index: field_name in field_language() (line 275 of /home/dixon/public_html/dev/modules/field/field.multilingual.inc).
* Notice: Undefined index: field_name in field_language() (line 275 of /home/dixon/public_html/dev/modules/field/field.multilingual.inc).
* Notice: Undefined index: field_name in field_language() (line 275 of /home/dixon/public_html/dev/modules/field/field.multilingual.inc).
* Notice: Undefined index: field_name in field_language() (line 275 of /home/dixon/public_html/dev/modules/field/field.multilingual.inc).
* Notice: Undefined index: field_name in field_language() (line 275 of /home/dixon/public_html/dev/modules/field/field.multilingual.inc).
* Notice: Trying to get property of non-object in entity_extract_ids() (line 7379 of /home/dixon/public_html/dev/includes/common.inc).
* Notice: Trying to get property of non-object in entity_extract_ids() (line 7379 of /home/dixon/public_html/dev/includes/common.inc).
* Notice: Undefined index: in _field_invoke_multiple() (line 299 of /home/dixon/public_html/dev/modules/field/field.attach.inc).
* Notice: Trying to get property of non-object in entity_extract_ids() (line 7379 of /home/dixon/public_html/dev/includes/common.inc).
* Notice: Undefined index: in _field_invoke_multiple() (line 299 of /home/dixon/public_html/dev/modules/field/field.attach.inc).
* Notice: Trying to get property of non-object in entity_extract_ids() (line 7379 of /home/dixon/public_html/dev/includes/common.inc).
* Notice: Trying to get property of non-object in entity_extract_ids() (line 7379 of /home/dixon/public_html/dev/includes/common.inc).

So I thought, right, I'll reinstall the media and file_entity modules and check it's not that, so I did, no help at all.

If I turn off my custom templates and modules, nothing happens either.

Next step was to take off my custom blocks....et voila. No errors.

So I know this is to do with either custom fields (input) views (process), blocks or templates (output).

A litle further diggin shoed that in views I see the same output of errors as I get on the front-end, so I know it's not the templates.

Turning off the blocks means I don't get front-end errors, but that doesn't mean anything, it just proves they aren't being outputted to screen.

So I go into views and start looking at settings, a lot of stuff seems to have changed in here since I last looked at it...in particular "aggregation settings". I don't remember those!

I start fiddling with these and when I click on "aggregation settings" I get a dropdown wih "Group by" shown, the default seems to be "value". I changed this to "entity_id" since I didn't know what it did and my errors started ot dissapear. I went through and did this for all fields and now the errors are gone.

What the hell?

I've spent weeks trying to fix this thinking it was something I'd set!

coderintherye’s picture

Well glad to know it's fixed for you.

I wonder if there is enough here that we can move this bug to views, though we'd need to have steps to reproduce this condition.

valante’s picture

Confirming the Views connection.

It just started happening for me on a single Node (not a Content Type!) when I made it include a view that uses aggregation on a Term reference field.

Other nodes of the same type that have data in this term reference field, but only one term (and so no actual aggregation is needed), do not throw this exception. Nor does this particular node throw the exception if the view is not aggregated.

Tal

silkAdmin’s picture

I am having the same issue when programmatically loading a node_form for a custom content type.

I used the following code :


function create_parce_node(){
	//module_load_include('inc', 'node', 'node.pages');
	global $user; 
	$account = user_load($user->uid);
	
	$node_type = 'parce';
  	$form_id = $node_type . '_node_form';
	
	$node = new stdClass();
	$node->uid = $user->uid;
	$node->bundle = $node_type;
	$node->title = $user->name . "'s Parce";
	$node->name = $user->name ;
	$node->field_city['und']['0']['value'] = $account->field_city['und']['0']['value'];
	$node->field_country['und']['0']['value'] = $account->field_country_select['und']['0']['value'];
	$node->type = $node_type;
	$node->language = LANGUAGE_NONE;
	$node->path = '';
	
	node_object_prepare($node);
	
	$return=drupal_get_form( $form_id ,$node );
	//krumo($return);
	echo drupal_render($return);
	exit;
}

Everything worked fine until i disabled the "Rebuild the theme registry on every page load " in the Development module..

After putting it back on seems to work again.. What is going on ?

silkAdmin’s picture

I just tried with a freshly created content type, with no fields attached.. Same problem :(

dddbbb’s picture

I only experience this error when I create nodes of a certain content type and only when logged in as a user with the Admin role (not just user 1). The error also shows when I try to view any of these newly created nodes but not when viewing nodes of the same content type that were created a while back (pre upgrade to 7.8).

I too have term reference fields in these problem content types but also have other content types that use term ref fields and don't throw the same error.

I've tried disabling relevant contrib modules but nothing seems to change.

Very frustrating. What's going on here folks?

coderintherye’s picture

To re-iterate, this is an error thrown due to a bug in contributed modules, though one that only came about because of a change in the Drupal's API with the 7.8 release.

To fix it, you really need to narrow down which module is causing the issue. This could be Views, Term Reference, etc.

If you were feeling snappy you could try unit tests to track down the problem, but for most people the easiest way to track it down will be by disabling contributed modules.

Try going to your module page, turning off 1 contributed module that you suspect may be the problem (e.g., Term Reference), then visit the page that was throwing the errors again. If that page no longer throws errors then bingo you now the module that was causing the problem and can go file a ticket in that module's issue queue (or see if one exists there for this problem already).

markosaurus’s picture

Anyone get any further with this...I'd love to know if this was a views bug! It's a module I use in every build, so squashing it would be top-priority for me and I'll gladly commit time to it to help in any way I can.

Post some info people!

dddbbb’s picture

Still no joy in tracking down what's causing it at my end. Troubleshooting has been made even harder by not being able to disable modules that create new fields (without deleteing whole lumps of content - not practical).

I can rule out Workbench Moderation, OG and Content Access.

mototribe’s picture

I ran into the "EntityMalformedException: Missing bundle property on entity of type taxonomy_term. in entity_extract_ids() (line 7389 of .../includes/common.inc)." error and I could reconstruct the steps:
- pretty new D7.8 install (Pantheon), added views, ctools, admin menu
- added topic taxonomy with a term reference to a TopicGroup taxonomy
- added a few nodes that have "topics" selected
- created view for type taxonomy/topics
- added relationship "content using topics"
- added nid and "comment count" fields
- enabled aggregate settings "group by"
- changed "nid" and "comment count" to use "count distinct"
- added field "taxonomy terms using TopicGroup"
- now I have an option for "group column": Tid is selected, when I apply and continue I get error
- when I recreate all the steps and select "entity_id" then the view works without errors.

patoshi’s picture

subscribe ... same problem -- screenshot: http://prntscr.com/3ay8k

EntityMalformedException: Missing bundle property on entity of type file. in entity_extract_ids() (line 7389 of /home/xxxx/public_html/dev/includes/common.inc).
The website encountered an unexpected error. Please try again later.

i turned off media module and my site started working again... i got that error on the frontpage which was basically a list of blog posts.

rkeppner’s picture

For those running into this problem when using aggregation in Views, there is a ticket open at http://drupal.org/node/1277296. However, I haven't yet managed to parse the described workaround, other than updated to the dev version.

wjaspers’s picture

is there a reason this is marked as "closed"?
AFAIK, this problem still exists....

dddbbb’s picture

Is it closed because it's not a core issue but a (very difficult to determine) contrib module issue?

coderintherye’s picture

Yes, this is not an issue with Drupal core, the error exists in a contributed module, and this error message is simply indicating that to you (perhaps not in the best way, but it is nevertheless). If you are experiencing the issue follow the instructions I gave earlier in the thread and then go look in the issue queue of the module giving you the problem or please see the linked to issues in this thread or file your own issue in the respective issue queue of the module giving you problems.

FreeFox’s picture

I had the same error but it was due to a typo. I loaded a node in PHP, change a field and than save it back.

$ndoe = node_load($nid);
$node->field_data = 'new data';
node_save($node);

But because of the typo, there was no node to save.

Hope this helps someone.

mgifford’s picture

I started getting this error after upgrading the Token module. Sadly reverting it didn't resolve the problems.

There didn't seem to be any database updates, so really not sure what could have happened...

EDIT: Applied this patch to core and it went away - http://drupal.org/node/1067750#comment-4941822

So I guess I should really track down where $entity->{$info['entity keys']['bundle']} === '' so that I can figure out which module was triggering this critical failure!

CraigSander’s picture

Definitely having the same issue and thinking it's Views-related.

BootstrapJohnny’s picture

My error of this type is being thrown by the Entity Reference contrib module. Basically, if I use the autocomplete widget, the AJAX is giving me this error. If I switch to the Dropdown widget, there are no errors, which makes it appear that the error is in the AJAX for the autocomplete for the Entity Reference.

Notably, I get no errors on the same widget in the Location module, so it's not a global thing, but I think just specific to the module that is using the autocomplete widget?

I hope this helps someone. I'm off to open an issue on the Entity Reference module.

dams_26’s picture

I've got the same error when I tried to create a new view (a term count view) and used the aggregation feature on my term field (I'm using autocomplete widget too).

killtheliterate’s picture

Version: 7.8 » 7.10

I've encountered this problem as well, and I don't see how this could be a contrib module issue, but rather one or more modules made core in d7.

I've used the below code to print node content somewhere besides the content area. In this instance, I'm printing a picture in the sidebar.

<?php

$nid = arg(1);
//node loading, so I can get field content
$node = node_load($nid);
$image = field_get_items('node', $node, 'field_image_aside');
// I though a conditional would fix this, but it didn't
if($image != '') {
	$output = field_view_value('node', $node, 'field_image_aside', $image[0], array(
	  'type' => 'image',
	  'settings' => array(
	    'image_style' => 'aside_image',
	  ),
	));

	print render($output);
}

?>

The only modules I've used are fields and image styles. I've dropped this code into a php block which I've put in the sidebar of my site. If I navigate to a page that doesn't have the 'field_image_aside', for instance, /user, I get the above error. I then have to disable my block via phpmyadmin, as I've only seen this so far while logged out.

This problem only occurs on pages where the region the block is being printed in exists.

killtheliterate’s picture

I fixed my issue by changing the above code to:

<?php
// I added this sanity check
if(arg(0) == 'node') {
	$nid = arg(1);
	$node = node_load($nid);
	$image = field_get_items('node', $node, 'field_image_aside');

	if($image != '') {
		$output = field_view_value('node', $node, 'field_image_aside', $image[0], array(
		  'type' => 'image',
		  'settings' => array(
		    'image_style' => 'aside_image',
		  ),
		));

		print render($output);

	}
}
?>

I needed to check if arg(0) == 'node'. Not sure why this would blow up so hard, though, if that check is skipped.

I guess the discussion about stricter error handling explains why this went from working to not.

Alex Andrascu’s picture

ndeschildre’s picture

The error message is confusing, but what it means is basically:
"The entity you gave me is invalid, it does not have a bundle attribut."
or, translated in the context of node entities,
"The node you gave me is invalid, it does not have a "type" attribute."

Just print_r($entity); before the exception being thrown, and you'll probably easily see why your entity is crap.

As such, this "bug" is only the symptoms of many many various bugs.

wxman’s picture

@ndeschildre
I did as you suggested as I was getting the same sort of errors after my upgrade. It keeps telling me it's a png attached to one of my news nodes. I tried editing the common.inc file as suggested in http://drupal.org/node/1266620#comment-4974982, and I was able to open the news file, edit, and save it. Once I removed the common.inc fix, the error came back. I guess I don't understand why the system can't figure out what to do with the png.

I have made it work without the common.inc hack. The only way I've found so far is open each file that has an attached picture, delete the picture, save, then edit it again adding the picture back in.

boran’s picture

FileSize
1.21 KB

For me this error happens when trying to editing certain fields imported from D6.
The fix was if ($entity_type=='node') , set $bundle = $entity_type;
patch attached.

This at least allows the field to be edited and the website does not crash.

boran’s picture

Status: Closed (works as designed) » Patch (to be ported)
tim.plunkett’s picture

Status: Patch (to be ported) » Closed (works as designed)

That's not what patch to be ported means. If anything, you would need to open an 8.x issue first.

Setting status back.

BeaPower’s picture

anyone have a fix? I am having this issue...

mikemadison’s picture

I think this may be an issue when upgrading from a particularly old version of Drupal to a new version. I just upgraded from 7.0 to 7.14, and I ran into this. There are some related issues with this error for specific modules (http://drupal.org/node/1565346 for Media Gallery and http://drupal.org/node/1576664 for Entity Reference).

The patch in #36 did fix this issue in my circumstance. Note that I did try some of the suggestions in the issues I've linked, but honestly, disabling every module on the site didn't the fix the problem for me. Hence my assumption that this could be an issue of upgrading content from older versions of D7.

peterx’s picture

For anyone diagnosing this error, I changed the message to the following. In the case I am researching, $entity is null.
throw new EntityMalformedException(t('Missing bundle property on entity of type @entity_type, property @property, in entity @x.', array('@entity_type' => $entity_type, '@property' => $info['entity keys']['bundle'], '@x' => serialize($entity))));

#36 did not fix the problem I am investigating. It was after an upgrade from 7.9 to 7.14. None of the listed "problem" modules are used on the site.

GN’s picture

I had this problem with some nodes, too, and patch #36 did not help me.
I fixed it by deleting from the `comment` table in the database some records related to deleted old comments (SELECT * FROM `comment` WHERE `status` =0) - they somehow caused 'EntityMalformedException' errors for nodes having no valid comments, only deleted ones.

Anonymous’s picture

patch #36 don't fix the issue.
It seems coming from video modulo upgrade from d6 to d7.

boran’s picture

Status: Closed (works as designed) » Active

Marking active again since several people have an issue still

drupalninja99’s picture

I am getting this from the acquia search results after a d6 to d7 upgrade

Preston McMurry’s picture

Trying to execute a field-only save, as outlined here: http://blog.urbaninsight.com/2011/10/24/saving-nodes-fields-without-savi...

Throwing same error: "EntityMalformedException: Missing bundle property on entity of type node. in entity_extract_ids() (line 7539 of /var/www-virtual/strategicvideoawards.com/htdocs/includes/common.inc)."

My code:

			$tmp = new stdClass();
			$tmp->id = $node->nid;      // node id
			$tmp->bundle = $node->type; // aka content type
			$tmp->field_ccnumber[LANGUAGE_NONE][0]['value'] = $node->field_ccnumber[LANGUAGE_NONE][0]['value'];
			field_attach_update( 'node', $tmp );

As soon as the call to field_attach_update() is attempted, it blows chow. (If I sprinkle dpm() debug statements before and after, the after is never rendered.)

If I change the 'node' to some random string like 'whygodmustIsuffer', then field_attach_update() throws no errors, but ironically neither does it successfully perform the update.

-----

p.s. Drupal 7.14. New install, not an upgrade. When I changed the error message as outlined in #41, I got this:

EntityMalformedException: Missing bundle property on entity of type node, property type, in entity O:8:&quot;stdClass&quot;:4:{s:2:&quot;id&quot;;s:2:&quot;29&quot;;s:6:&quot;bundle&quot;;s:4:&quot;node&quot;;s:14:&quot;field_ccnumber&quot;;a:1:{s:3:&quot;und&quot;;a:1:{i:0;a:1:{s:5:&quot;value&quot;;s:15:&quot;xxxxxxxxxxx0002&quot;;}}}s:18:&quot;field_prevent_save&quot;;a:1:{s:3:&quot;und&quot;;a:1:{i:0;a:1:{s:5:&quot;value&quot;;i:1;}}}}. in entity_extract_ids() (line 7540 of /var/www-virtual/strategicvideoawards.com/htdocs/includes/common.inc).

-----

edit: field_attach_presave() also blows ass.

edit: If I pass $node directly to field_attach_update(), rather than via the temporary object, it proceeds without throwing the cited error. However, it does not actually perform the update (i.e. the same misbehavior as when I changed node_type to 'whyGodmustIsuffer') ...

xjm’s picture

Status: Active » Closed (works as designed)

When you encounter these issues, look for or file an issue with the module that is causing the exception. Drupal core is returning a legitimate error message about bad data is being passed, so it needs to be fixed in the module passing that data.

peterx’s picture

@xjm, one of the problems with Drupal is finding "the module passing that data". I usually have to expand the error messages to list the data. If the data is empty or generic, it still does not point back to anything definitive. Adding a backtrace helps. Drupal could do with a help page on how to mode core with full diagnostics to pin down the source of the data.

Perhaps the error message could be expanded to include the bundle property and entity id.

peterx’s picture

FileSize
1.22 KB

Here is a patch to help people debug. My most recent need for this was caused by an out of date Field permissions module. There were several previous uses for other problems.

mgifford’s picture

#49 has a bunch of notice errors and the core patch really doesn't produce something that is easy to track down to the Module.

I'm using Field Permissions 7.x-1.0-beta2, so there must be a conflict somewhere else, but the object is messy when it gets to Watchdog.

albertski’s picture

#49 - Updated the Field Permission Module (last updated on June 25, 2012) and my Problem went away! :)

mgifford’s picture

@albertski this module here wasn't updated on June 25th:
http://drupal.org/project/field_permissions/

Please give me some more details.

HongPong’s picture

This may be a tangent but if you have malformed files entities - see #1446440: Unable to view me media management pages (EntityMalformedException: Missing bundle property...) for my one-off SQL fix for column type in the files_managed table.

albertski’s picture

Sorry it was updated Jan 25th. I guess I had an older version that one. When I updated it, the problem went away.

albertski’s picture

I experienced this error again on some articles and I figured out Why I get the error. These are the steps to reproduce this error.

My article content type has a "company" node reference auto complete field.

  1. Create a company
  2. Create an article
  3. add a different company in the first position
  4. add company from first step in the second position
  5. View article and notice no error
  6. Delete company created in first step
  7. view article and you will get an error (error log: EntityMalformedException: Missing bundle property on entity of type node. in entity_extract_ids() (line 7539......)
  8. You can go back and remove the blank company from the article and the error goes away

Not sure if this is what causing everyone's problem but I am seeing that if you delete a node that is referenced in another node by node reference, it does not delete that referenced node from the node.

albertski’s picture

#55 - The Reference Delete Module will prevent this issue to happen in the future but won't fix the issue if you already have this issue. In my case I deleted a couple company nodes that were causing this issue only on my dev instance. :)

a6hiji7’s picture

I am facing this issue. What is happening is that whenever a taxonomy term is deleted, every node that referred to that term throws this error. I have checked with a basic Drupal installation and the issue was not there; I was able to delete terms without causing any issue with nodes that referred to them. In the site where I am having the issue, I checked the database and see that the table corresponding to the term reference field still has the reference records. Deleting the records from the table actually solves the issue. However I have not been able to find which module is causing the records to be not deleted.

RowboTony’s picture

a6hiji7, the module which seems to cause this for me is Drupal Commerce. I have product attributes which are in fact taxonomy terms, this seems to be what is causing my EntityMalformedException error :(

nicodv’s picture

In fact, I have the same error. What i did:

Create a new node using a different user than admin
Delete it
Now admin can create new nodes of that content type but the other user can't and throws the error.

The node had 2 entity ref fields, but in the db I can't see anything I can delete.

What should I look at? the entity ref fields tables in the db? and what trace should I see that tells me that the deleted node left a reference pointing at it?

thanks

a6hiji7’s picture

For me the field was named "field_shared_topic" and the table that had references to missing terms was "field_data_field_shared_topic". I installed the "Field reference delete" module (http://drupal.org/sandbox/drothstein/1775816) and that seems to have fixed the issue.

flock’s picture

FileSize
414.06 KB
409.03 KB

Drupal Core 7.16
I agree with this. I deleted 2 taxonomy terms and my blog view stopped working:

Error
The website encountered an unexpected error. Please try again later.

When I got into views, and views attempted to load the preview:
An AJAX HTTP error occurred.
HTTP Result Code: 500
Debugging information follows.
Path: /2012/admin/structure/views/view/news/preview/page/ajax
StatusText: error
ResponseText: EntityMalformedException: Missing bundle property on entity of type taxonomy_term. in entity_extract_ids() (line 7562 of /home/content/b/1/9/b19842723/html/2012/includes/common.inc).

Went into the Reports are and found two terms missing, attaching the JPGs for reference. Today I will try to get into the database and delete those reference records even though i'm a newb at SQL.

--------solved---------
Intalled: http://drupal.org/project/taxonomy_orphanage
Ran it through the admin pages and it solved my troubles.

cbrasfield’s picture

Version: 7.10 » 7.16

rm

kclarkson’s picture

@Flock !!!

Thank you so much !!! You just saved my day !!!!

taxonomy_orphanage worked !

kacash’s picture

In my case the error was triggered by PHP code I'd written into a custom block. The tip-off that it was in a block was that the error disappeared when using other themes.

Basically I was trying to retrieve CCK fields from a node which didn't always exist. The fix was to add a constraint for if($node != false)

markosaurus’s picture

How did we ever get into a position where these were not rmeoved I wonder? That is somewhat ponderous.

Does not matter so much I would think now that it is being addressed. I've used Drupal for years and seen this error many times without knowing that fix existed, so thanks for that @flock.

Anyone know if this is being fixed in D8 core? Has it ben raised?

kenorb’s picture

@markosaurus: Yes, it's raised in 8.x as mentioned in #65
See: #1281114: Database records not deleted for Term Reference Fields after Term is Deleted

Summit’s picture

Hi,
#36 fixed it for me temporarely , thanks!
Greetings, Martijn

jm_drupal’s picture

Hi, I was getting "EntityMalformedException" error when i try to access any views 'page display' only. "Views block display" was working ok. This Patch in #3 fixes my problem. Thanks.

jfcolomer’s picture

Issue summary: View changes

Forcing to reload the node, worked for me:

$mynode = node_load($node->nid, NULL, true);

However I need to find out why it did not find my node bundle therefore is not able to fetch the node from cache.

Regards,
Juan

ehsankhfr’s picture

Most of the times its because of your unmanaged coding. For example having different validation functions for one form in different modules, and one of them faces with problem in using entities!

So Most of the times Drupal is innocent!

adhariwal’s picture

FileSize
1.51 KB

#36 Fixes the issue for node entity this has to be done for taxonomy_terms too. The update patch file is attached.

nayanalok’s picture

FileSize
1.67 KB

Need to add else condition if entity property is not set. Here is the updated patch on top of #72

bobburns’s picture

still there as of 7.66 - needs to get committed to core

apaderno’s picture

apaderno’s picture

Version: 11.x-dev » 7.x-dev