Good evening all. A few weeks ago I attempted an upgrade from 7.7 to 7.8 and got the following error as a result;

EntityMalformedException: Missing bundle property on entity of type node. in entity_extract_ids() (line 7389 of /home/dixon/public_html/dev/includes/common.inc).

Not brilliantly helpful since I have a lot of modules installed and didn't really know where to start. Reading up on the issue and I see that this has occurred a lot with people upgrading to 7.8. Since not many people have found fixes that work (at least that I have seen) I thought I'd have a go myself.

So I ran a backtrace from bootstrap.inc and got the following as output (thanks to this lovely article - http://www.lullabot.com/articles/quick-and-dirty-debugging), but I don't really know where to go from here. I guess stepping through the array provides more information, but I still don't know how to resolve it? (Array included at the end in case anyone can shed any light on it and save my sanity).

Array
(
[0] => Array
(
[file] => /home/dixon/public_html/dev/includes/errors.inc
[line] => 248
[function] => drupal_set_message
[args] => Array
(
[0] => EntityMalformedException: Missing bundle property on entity of type node. in entity_extract_ids() (line 7389 of /home/dixon/public_html/dev/includes/common.inc).
[1] => error
)

)

[1] => Array
(
[file] => /home/dixon/public_html/dev/includes/bootstrap.inc
[line] => 2166
[function] => _drupal_log_error
[args] => Array
(
[0] => Array
(
[%type] => EntityMalformedException
[!message] => Missing bundle property on entity of type node.
[%function] => entity_extract_ids()
[%file] => /home/dixon/public_html/dev/includes/common.inc
[%line] => 7389
[severity_level] => 3
)

[1] => 1
)

)

[2] => Array
(
[function] => _drupal_exception_handler
[args] => Array
(
[0] => EntityMalformedException Object
(
[message:protected] => Missing bundle property on entity of type node.
[string:private] =>
[code:protected] => 0
[file:protected] => /home/dixon/public_html/dev/includes/common.inc
[line:protected] => 7389
[trace:private] => Array
(
[0] => Array
(
[file] => /home/dixon/public_html/dev/modules/field/field.multilingual.inc
[line] => 265
[function] => entity_extract_ids
)

[1] => Array
(
[file] => /home/dixon/public_html/dev/modules/field/field.module
[line] => 917
[function] => field_language
[args] => Array
(
[0] => node
[1] => Array
(
[0] => Array
(
[fid] => 9
)

)

)

)

0 - Shows me the general set message function is invoked to print it out for me, nothing new there.
1 - Shows drupal_log_error was invoked to print an error with entity_extract_ids (first message told us this anyway)
2 - Shows entity_extract_ids had an error in that on line 265 there was a malformed entity passed to it.

So I go to modules/field/field.multilingual.inc ln 265 and in there I find this;

list($id, , $bundle) = entity_extract_ids($entity_type, $entity);

I now know that this line is throwing a wobbler when being passed a malformed $entity (or more likely, not being passed anything due to bad error checking in the module). So I try to get more information;

print_r($entity); above ln 265 gives us this;

stdClass Object
(
[vid] => 4
[uid] => 0
[title] => Portfolio
[log] =>
[status] => 1
[comment] => 0
[promote] => 0
[sticky] => 0
[nid] => 4
[type] => page
[language] => und
[created] => 1294493662
[changed] => 1298321372
[tnid] => 0
[translate] => 0
[revision_timestamp] => 1298321372
[revision_uid] => 1
[body] => Array
(
)

[rdf_mapping] => Array
(
[rdftype] => Array
(
[0] => foaf:Document
)

[title] => Array
(
[predicates] => Array
(
[0] => dc:title
)

)

[created] => Array
(
[predicates] => Array
(
[0] => dc:date
[1] => dc:created
)

[datatype] => xsd:dateTime
[callback] => date_iso8601
)

[changed] => Array
(
[predicates] => Array
(
[0] => dc:modified
)

[datatype] => xsd:dateTime
[callback] => date_iso8601
)

[body] => Array
(
[predicates] => Array
(
[0] => content:encoded
)

)

[uid] => Array
(
[predicates] => Array
(
[0] => sioc:has_creator
)

[type] => rel
)

[name] => Array
(
[predicates] => Array
(
[0] => foaf:name
)

)

[comment_count] => Array
(
[predicates] => Array
(
[0] => sioc:num_replies
)

[datatype] => xsd:integer
)

[last_activity] => Array
(
[predicates] => Array
(
[0] => sioc:last_activity_date
)

[datatype] => xsd:dateTime
[callback] => date_iso8601
)

)

[name] =>
[picture] => 0
[data] =>
[uri] => Array
(
[path] => node/4
[options] => Array
(
[entity_type] => node
[entity] => stdClass Object
*RECURSION*
)

)

)

Now I'm stuck, I have no idea what's causing the recursion! I also have nowhere to go with this.

I checked my database in the node table and everything looks fine in there, and I also checked in the

This looks like there is recursion happening when node 4 is called, a particular problem with the entity type perhaps? This looks well formed in the database though?

Help! Is this a bug? Should I log it as one? I'm not the only person getting this problem after this update, which leads me to believe that this should be resolved in core if it breaks as a result of an update.

Comments

alexberriman’s picture

I also received the above error after upgrading from 7.7 to 7.8. I assumed it was just the fact that there have been some changes to how the content was stored/managed in 7.7. It was a rather fatal exception for me, I had the fb module outputting the exception and then terminating page output, so as a temporary fix I just commented it out.

./includes/common.inc line 7389
Replace:
throw new EntityMalformedException(t('Missing bundle property on entity of type @entity_type.', array('@entity_type' => $entity_type)));

With:
//throw new EntityMalformedException(t('Missing bundle property on entity of type @entity_type.', array('@entity_type' => $entity_type)));

Not the most elegant solution, but if you can't even access the content page, like I couldn't, it should at least free it up.

markosaurus’s picture

As a matter of course, this might help sidestep the issue during debugging, but I would never leave that comment in place in core code (As soon as you update again it will be overwritten).

Once I commented that out, I receive further errors such as this;

Undefined index: field_name in field_language() (line 276 of /home/dixon/public_html/dev/modules/field/field.multilingual.inc).

Looks like it's trying to continue on, but because we have just sidestepped the problem rather than fixing it, we'll just see more errors.

I need to work out what the error is and then fix it :(

WH’s picture

I upgraded from 7.7 to 7.8 without (too many) problems.
I only just saved down and activated the File Entity Module (7.x-1.0-beta5) today, and then immediately started getting a very similar error. I haven't had a chance to investigate further, but disabling this module has stopped the errors for the time being.

Hope that helps narrow things down!

markosaurus’s picture

I don't have that module installed unfortunately!

I've done some more digging around though, and found out that the line causing the problem (for me anyway) is here;

modules/field/field.multilingual.inc (Ln 265)

list($id, , $bundle) = entity_extract_ids($entity_type, $entity);

The error is telling me that something it is trying to call out of the database has a missing bundle property for an intity of type node. Just knowing it is a node is not very helpful, so I deleted all content apart from one entry to allow me to trace through the database and seek the problem faster.

I put a print_r($entity) in above that live and get the following recursion;

stdClass Object
(
[vid] => 4
[uid] => 0
[title] => Portfolio
[log] =>
[status] => 1
[comment] => 0
[promote] => 0
[sticky] => 0
[nid] => 4
[type] => page
[language] => und
[created] => 1294493662
[changed] => 1298321372
[tnid] => 0
[translate] => 0
[revision_timestamp] => 1298321372
[revision_uid] => 1
[body] => Array
(
)

[rdf_mapping] => Array
(
[rdftype] => Array
(
[0] => foaf:Document
)

[title] => Array
(
[predicates] => Array
(
[0] => dc:title
)

)

[created] => Array
(
[predicates] => Array
(
[0] => dc:date
[1] => dc:created
)

[datatype] => xsd:dateTime
[callback] => date_iso8601
)

[changed] => Array
(
[predicates] => Array
(
[0] => dc:modified
)

[datatype] => xsd:dateTime
[callback] => date_iso8601
)

[body] => Array
(
[predicates] => Array
(
[0] => content:encoded
)

)

[uid] => Array
(
[predicates] => Array
(
[0] => sioc:has_creator
)

[type] => rel
)

[name] => Array
(
[predicates] => Array
(
[0] => foaf:name
)

)

[comment_count] => Array
(
[predicates] => Array
(
[0] => sioc:num_replies
)

[datatype] => xsd:integer
)

[last_activity] => Array
(
[predicates] => Array
(
[0] => sioc:last_activity_date
)

[datatype] => xsd:dateTime
[callback] => date_iso8601
)

)

[name] =>
[picture] => 0
[data] =>
[uri] => Array
(
[path] => node/4
[options] => Array
(
[entity_type] => node
[entity] => stdClass Object
*RECURSION*
)

)

)
stdClass Object
(
[vid] => 4
[uid] => 0
[title] => Portfolio
[log] =>
[status] => 1
[comment] => 0
[promote] => 0
[sticky] => 0
[nid] => 4
[type] => page
[language] => und
[created] => 1294493662
[changed] => 1298321372
[tnid] => 0
[translate] => 0
[revision_timestamp] => 1298321372
[revision_uid] => 1
[body] => Array
(
)

[rdf_mapping] => Array
(
[rdftype] => Array
(
[0] => foaf:Document
)

[title] => Array
(
[predicates] => Array
(
[0] => dc:title
)

)

[created] => Array
(
[predicates] => Array
(
[0] => dc:date
[1] => dc:created
)

[datatype] => xsd:dateTime
[callback] => date_iso8601
)

[changed] => Array
(
[predicates] => Array
(
[0] => dc:modified
)

[datatype] => xsd:dateTime
[callback] => date_iso8601
)

[body] => Array
(
[predicates] => Array
(
[0] => content:encoded
)

)

[uid] => Array
(
[predicates] => Array
(
[0] => sioc:has_creator
)

[type] => rel
)

[name] => Array
(
[predicates] => Array
(
[0] => foaf:name
)

)

[comment_count] => Array
(
[predicates] => Array
(
[0] => sioc:num_replies
)

[datatype] => xsd:integer
)

[last_activity] => Array
(
[predicates] => Array
(
[0] => sioc:last_activity_date
)

[datatype] => xsd:dateTime
[callback] => date_iso8601
)

)

[name] =>
[picture] => 0
[data] =>
[uri] => Array
(
[path] => node/4
[options] => Array
(
[entity_type] => node
[entity] => stdClass Object
*RECURSION*
)

)

[_field_view_prepared] => 1
[entity_view_prepared] => 1
[content] => Array
(
)

)
Array
(
[0] => Array
(
[fid] => 10
)

)

Now I'm stuck again, I'm getting closer, but rapidly losing patience.

ashoksakra’s picture

Hello Friends,

I am getting the error that is mentioned below. Please help me to get rid out of this,

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

Thanks
Ashok Sakra

joshua.stout’s picture

I commented out line 7539, took at look at my content list. Saw 3 malformed entities. Deleted them. Commented 7539 back in. Good to go.

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.

Anonymous’s picture

A little late but perhaps for the next person coming along. This error is caused by existence of some corrupt node id in the node table. the best way to deal with this is to remove the node id from the node and all other tables. This fix works for mysql only. Use the following steps.

Requirements:

You need drush for make this simple.

Steps

1. Copy the following code into a file e.g. junk.php

<?php

// start of code
$result = db_query("select nid, title from node where title = ''") ;

foreach ($result as $row){
try {
$node = node_load($row->nid) ;
}
catch(Exception $e){
// print_r($e) ;
// echo $e->getMessage() . "\n";
if ('Missing bundle property on entity of type node.' == $e->getMessage()){
//select distinct table_name, column_name from information_schema.COLUMNS where column_name in ('nid', 'entity_id') ;
$types = array('nid', 'entity_id') ;
$tables = db_query("select distinct table_name, column_name from information_schema.COLUMNS where column_name in (:q)", array(':q' => $types));
foreach($tables as $t) {
echo "Deleting from table " . $t->table_name . " nid = " . $row->nid . "\n" ;
db_delete($t->table_name)->condition($t->column_name, $row->nid)->execute() ;
}

}

}
}

// end of code

2. run the command drush -l http://www.example.com scr junk

-- http://www.example.com is your website address

-- junk is the name of your script containing the above php code.

Hope someone finds this useful.

Abyooda’s picture

I created a file called junk.php and run it by going to www.strongerstudents.com/junk.php and this what happened

Fatal error: Call to undefined function db_query() in /home/content/61/10191161/html/junk.php on line 4

babruix’s picture

You need to add after <?php this:

define('DRUPAL_ROOT', '.'); // or define('DRUPAL_ROOT', '/');
require_once DRUPAL_ROOT . '/includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
tcowin’s picture

This was a great help - thanks for the post. I just wanted to add, if you have more than one drupal installation in your database, - or if the script errors out with a table not found error - you'll need to add a clause to your db query specifying the name of your drupal db:

            $tables = db_query("select distinct table_name, column_name from information_schema.COLUMNS where table_schema = 'drupal_db_name' AND column_name in (:q)", array(':q' => $types));

It can also be run from your browser:

http://www.example.com/junk.php

rajeesh’s picture

Hi Nantogmah,

You really saved my day. For the past day I was plucking my hair to fix this issues. The drush solution was worked like a charm. I got the node id from it and I removed the same from db - problem solved.