When trying to edit a term reference field on my content type "manage fields" page I get the following error:

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

What is causing this error???

Comments

Back From 7’s picture

Found the issue. The field permissions module was somehow throwing the error. I removed the field permissions module and fixed the issue...

stugacz’s picture

If field permissions module is not installed would there be also be some other cause and solution?

RYL’s picture

Hi,

Same comment as above.
Field permission is not installed on my D7 site.

Back From 7’s picture

Try to delete the field and redo it! This all happened when we edited taxonomy vocabulary name. Try to create a fresh term reference field on your content type.

adroid’s picture

Hi!

Same error but I get it each time when cron runs.
Cron should create new nodes of type "feed_item" by importing RSS feeds(Feeds).
But "feed_item" content type doesn't have any taxonomy term reference fields - so might it be deeper issue?

mgifford’s picture

We got this from version 7.x-1.0-rc3+10-dev (2012-Sep-06) but think that should have stuff missing from 7.x-1.0-rc3 (2012-May-25).

Not familiar enough with entities to dig much further into this but:
http://api.drupal.org/api/drupal/includes!common.inc/function/entity_ext...

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

Some related modules we've got enabled:
Entity Reference 7.x-1.0-rc3
Entity Translation 7.x-1.0-alpha2
File entity 7.x-2.x-dev
Hierarchical Select Entity Reference 7.x-1.x-dev

xaa’s picture

hi, I've the same error after have deleted a term. All nodes or pages (as taxonomy pages) that was refering to the term deleted don't work and display the error message.

xaa’s picture

#4 works but don't fix the problem :)

marcoBauli’s picture

Same error, but removing the two Term reference fields didn't help..... Field permission not installed..

EDIT: the error was caused by the Dragndrop_uploads module. Disabling it made things work fine again!

kclarkson’s picture

@marcoBauli

How did you debug to find the module that was causing the error ?

marcoBauli’s picture

well not really debugged, just used dichotomic method: disabled modules till i found the culprit.

Tokoh’s picture

I have the same error. I have created a new entity of type node called "Property". (Sorry the name might be confusing. Here a Property refers to a block of land). If I try to create a new Property it generates this error. However it only occurs if I try to preview a new "Property". If I save then there's no problem If I try to open an existing Property and then preview it, no problem.
I have pulled all of the fields of the entity so now its just the content with its title. However the entity does use the gmap and location modules and I wonder if this is creating my problem.
When I try to look at the entity that generates the problem its virtually empty, just b:0.
I have no idea of how to go about dealing with this problem. Any suggestions would be welcome.

adroid’s picture

I've nailed it down for my project - maybe it helps if write a long story and describe how I did it. :)

Problem cause in my case

Problem cause in my case were some orphaned nodes in node table. I have no idea why they existed but there were about 4 of them.
It means that entries existed in node table, but they were "empty" nodes - they didn't have any entries on other tables like field_data_body, node_revision and so. And when I tried to do 'node_load()' on them, it silently failed and returned false.

How I tracked it down

As I mentioned on comment #5
I got this error each time when cron was run. And on each cron run, nodes of type 'feed_item' was created and processed. So I knew that issue in my case was with nodes of type 'feed_item'.

So next I used PHP's function called debug_backtrace and I put it right before the line 7562 - before the line

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

and run the cron again (to cause that 'Missing bundle property...' error).

debug_backtrace showed all functions that were called prior the error and what parameters were passed. I kept my eye on node id's.
From that output I saw that at some point there was issue with node id-s and node loading.
In my case the failing node ID was 555. So I took the problematic node id and tried to load it: node_load(555);
node_load failed and var_dump returned false.

Then I went to database and looked node table and saw that this node is still there - weird.
After searching from other tables I found that this node was kind of "ghost" node - it didn't have any entries in other tables(although in my case, there should be entries at least in field_data_body and node_revision table regarding to that node).

Problem solution in my case

  1. I made backup of database. (!)
  2. Deleted that faulty node directly from node table.
  3. Started cron again and it had one error less - so that action had positive effect.

Then I wrote query to see if there are any other "ghost" nodes for content type 'feed_item' - I compared node and node_revision table to get all nodes which have entry in node table but don't have entry in node_revision table:

// I used PHP formatting just to color the 'feed_item' part in my post...you should run this query in phpMyAdmin or similar.
SELECT
        n.nid,
        n.title,
        n.vid,
        nr.vid
      FROM
        node n
      LEFT JOIN
        node_revision nr
        ON nr.nid = n.nid
      WHERE
        n.type = 'feed_item'
        AND nr.vid IS NULL
      ORDER BY
        n.nid ASC

I ran this query for all my content types by changing the line n.type = 'feed_item' to reflect any content types I had.
If I had content type with machine name 'regular_page', I changed that part to: n.type = 'regular_page'

On ideal case and when everything is OK, this query should output 0 rows.
When there are issues with ghost nodes, it outputs their id and title and so - these are the nodes that caused the error because Drupal fails to load them by node_load().

That was it - by removing these few nodes, errors were gone.(and if they haven't died, they live happily ever after somewhere else. :))

castawaybcn’s picture

I am getting the same error. In my case it shows when trying to edit a node which contains Entity references (both users and node), this might be similar to @mgifford's case.

gooney0’s picture

I had the same issue. In my case I was querying a field_data_field_xxx table. It had a row which didn't correspond with any node.

I deleted the row and the error went away.

minorOffense’s picture

I'm getting the same error message except I only get it when trying to add a new term via the node edit for using the autocomplete (tags) widget.

We have entity translation enabled along with field translations for the taxonomy terms.

There are two taxonomy reference fields on the node (each pointing to a different vocabulary) and adding a new term to either one causes the error.

I'm not entirely convinced this is entity API's fault. Taxonomy and Node entities don't use Entity API?

Does this issue occur for anyone without Entity API installed?

LTech’s picture

I have this error: EntityMalformedException: Missing bundle property on entity of type node. in entity_extract_ids() (line 7642 of /xxx.xom/mg-testsite.com/ubercart/includes/common.inc).
The website encountered an unexpected error. Please try again later. and it is crashing my whole site. I thought I had it sorted by deleting the media module, the error went away but now it is back again.
help my site is a white page!

LTech’s picture

Issue tags: +taxonomy field

On a 2nd site I have this error only shows on the xxx.com/blog page which displays a wordpress blog view.
I think the errors started when I installed the media module but now I've uninstalled it I still can't get rid of the error.

kingswoodute’s picture

Hi Same Error,

EntityMalformedException: Missing bundle property on entity of type node. in entity_extract_ids() (line 7633 of /var/www/html/ssws/includes/common.inc).

Going to try the process outlined in #13. Thanks for posting that!

oteno’s picture

Hello,
i got the same error. Solution in #13 worked great.
Thanks a lot @adroid

30equals’s picture

Just fyi,

mine was related with #1851118: Incorrect ET Handler set in node/add form when inserting new taxonomy term - so not really an entity api issue in my case (ended up here via Google) - but it might help maybe.

kenorb’s picture

This was happening during search, so view was loading the invalid nodes.

Backtrace:

Call Stack:
    0.0002     648632   1. {main}() /index.php:0
    0.5264   63413184   2. menu_execute_active_handler($path = ???, $deliver = ???) /index.php:21
    0.5266   63414376   3. call_user_func_array('views_page', array (0 => 'job_search', 1 => 'job_search')) /includes/menu.inc:517
    0.5266   63414992   4. views_page($name = 'job_search', $display_id = 'job_search') /includes/menu.inc:517
    0.5907   84765328   5. view->execute_display($display_id = 'job_search', $args = array ()) /views/views.module:526
    0.6812   97594584   6. views_plugin_display_page->execute() /views/includes/view.inc:1337
    0.8044  104191184   7. view->render($display_id = ???) /views/plugins/views_plugin_display_page.inc:229
    1.0337  111350456   8. views_plugin_style->pre_render($result = array (0 => class stdClass { public $entity = 3046; public $_entity_properties = array ('search_api_relevance' => 1.5091631, 'search_api_excerpt' => '', 'search_api_id' => '3046', 'search_api_item_id' => '3046', 'type' => 'ad', 'title' => 'sales', 'status' => 1, 'promote' => FALSE, 'sticky' => FALSE, 'created' => 1361878141, 'changed' => 1361979353, 'field_job_client_hide' => FALSE, ...)) })) /views/includes/view.inc:1236
    1.0338  111350456   9. entity_views_plugin_row_entity_view->pre_render($values = array (0 => class stdClass { public $entity = 3046; public $_entity_properties = array ('search_api_relevance' => 1.5091631, 'search_api_excerpt' => '', 'search_api_id' => '3046', 'search_api_item_id' => '3046', 'type' => 'ad', 'title' => ... })) /views/plugins/views_plugin_style.inc:307
    1.0504  111354496  10. entity_view($entity_type = 'node', $entities = array (0 => NULL, 1 => NULL, 2 => NULL), $view_mode = 'browse', $langcode = ???, $page = ???) /entity/views/plugins/entity_views_plugin_row_entity_view.inc:76
    1.0504  111355088  11. entity_metadata_view_node($entities = array ('' => NULL), $view_mode = 'browse', $langcode = NULL, 'node') /entity/entity.module:523
    1.0504  111355168  12. node_view_multiple($nodes = array ('' => NULL), $view_mode = 'browse', $weight = 0, $langcode = NULL) /entity/modules/callbacks.inc:813
    1.0504  111355304  13. field_attach_prepare_view($entity_type = 'node', $entities = array ('' => NULL), $view_mode = 'browse', $langcode = NULL) /modules/node/node.module:2578
    1.0504  111357136  14. field_language($entity_type = 'node', $entity = NULL, $field_name = NULL, $langcode = NULL) /modules/field/field.attach.inc:1111
    1.0505  111358032  15. entity_extract_ids($entity_type = 'node', $entity = NULL) /modules/field/field.multilingual.inc:268
    1.0505  111358448  16. xdebug_print_function_stack('Missing bundle property on entity of type node') /includes/common.inc:7633


Variables in local scope (#15):
  $bundle = *uninitialized*
  $entity = NULL
  $entity_type = 'node'
  $id = NULL
  $vid = NULL

Workaround was to re-save some nodes which had some wrong references during the import.

Here is sql query which I've used to track the invalid references:

drush sqlq "SELECT nid, title from node WHERE nid IN (select entity_id from  field_data_field_some_ref WHERE field_some_ref_tid not IN (select tid from taxonomy_term_data));"

Where field_data_field_some_ref is data field of field_some_ref which is type of 'Term reference'.

kenorb’s picture

PapaGrande’s picture

In case anyone else is looking for clues to debugging an EntityMalformedException error, I found that when calling field_get_items() and the entity is missing, my page borked without a graceful error message. Adding a test for a valid entity before calling field_get_items() fixed it.

mattheweigand’s picture

The procedure in #13 worked for me. I had installed a CPU-limiting script on my amazon AWS micro server (http://cpulimit.sourceforge.net/) in order to try to limit the amount of CPU time my Drupal 7 instance was running. During the day that I had this web server thing running, I tried to create some new nodes and got a PHP timeout error. I ended up removing CPULimit because of this. But each time I got an error in making a new node I had inadvertently created what #13 describes as a "ghost" node. These ghost nodes could not be processed by search and caused search indexing to stop. Two weeks later I realized that no new nodes were being indexed. I ran drush search-reindex --immediate --verbose on my server and got the error "WD php: EntityMalformedException: Missing bundle property on entity of type node. in entity_extract_ids()". A google search led me to this thread, and I followed the procedure in #13 and deleted 8 "ghost" nodes. After that I reindexed the site and everything works perfectly.

tatewaky’s picture

Hi PapaGrande or anyone, how can i validate if a entity is valid or not? im looking for the answer in google but i can't found it, if you guys have the answer that would be killing, thanks.

PapaGrande’s picture

@tatewaky, I believe I just did a !empty() test on the entity variable before calling field_get_items().

tatewaky’s picture

Thanks @papagrande i'll check it out.
:)

nasia123’s picture

I run the query from #13, and got 0 results
I also installed orphaned_taxonomy which found some orphaned taxonomy terms and fixed them.
but I still get the error ...

The error in my case is displayed when I use the preview node option in a node that has workbench moderation enabled.
I am also using field group.

Yuri’s picture

Issue summary: View changes

module orphaned taxonomy 0 (zero) results. Still this error happens when adding a node that has an entity reference field that is used for tagging, while a new term is inserted that does not yet exist in the taxonomy. When a term is selected that is already available, the error does not appear.

thermador’s picture

#13 worked for me, thank you SO MUCH. Because of one single orphaned node, my Drupal 7 site's search module wouldn't complete reindexing past that node. So I couldn't reindex the site, nor add to the existing index (via cron) when new content was posted.

I found this thread because I was using "drush cron --verbose" at the command line to try and figure out why reindexing wouldn't complete, and I got the "EntityMalformedException: Missing bundle property on entity of type node. in entity_extract_ids()" error message.

Ed Vogt’s picture

Using commerce and feeds, same issue.

Removed the orphaned feeds_item, guid records.

All good.

Rahul Seth’s picture

still facing "EntityMalformedException: Missing bundle property on entity of type node.

amir0220’s picture

#13 was my solution. node_load($nid) was failing because $nid was empty in some cases. Didn't have to dig too much to find where the problem was because it happened on the last thing I modified on the code and I knew where that was.
:)

Exploratus’s picture

THat is my problem, created sometimes when a large feeds import crashes. The node revision entry fails to get created. The problem is I have 89 tables, is there an easy way to go through and delete orphaned fields / nodes with missing revision entry?

Kattia’s picture

I have this issue happening on workflow fields I am using buttons to show the state

jasonaaronwood’s picture

I was just in the middle of converting a few nodes to another node type and suddenly got this error.

EntityMalformedException: Missing bundle property on entity of type node. in entity_extract_ids() (line 7633 of /home/content/40/5305940/html/includes/common.inc).

It completely blocks off my ability to:
*view/edit the node
*view the panels page where it was previously featured (I was editing via the panels "gear" icon)
*view the admin/content list

I can tell it's node 672 because that's the one it won't let me view; all the others seem fine. How do I delete a node from the node table (sorry, I'm sure it's not too hard but I just don't know where to start)?

j.am’s picture

I am getting this error when I try to access any system page.

Front facing website is fine, I can navigate all published pages as anonymous, but I can't get to the login page because of this error, so I'm effectively shut out of the site admin.

Error message
    Notice: Undefined variable: node in include() (line 54 of /home/cmrcccos/public_html/sites/all/themes/cmrc/layouts/standard/standard-layout.tpl.php).
    EntityMalformedException: Missing bundle property on entity of type node. in entity_extract_ids() (line 7734 of /home/cmrcccos/public_html/includes/common.inc).
The website encountered an unexpected error. Please try again later. 

The structure of my theme is still being rendered, everything before the content, then it fails to load the node, and everything after that, the node, the footer, does not appear.

This does not happen for any of the nodes I have created, they render fine, but when I go to a system node: user/login, admin/*, or a node that does not actually exist like node/3000, it gives me the missing bundle error instead of the content.

SOME TIME LATER....

My issue was caused by rendering a field by calling

print render(field_view_field('node', $node, 'field_top_image', array('label' => 'hidden')));

in my layout.tpl.php (ie page.tpl.php if I was not using omega 4 layouts). The field_view_field function is not recommended for templates, and my issue would be one of the reasons why.

Fixed by rendering a field by calling

print render($page['content']['system_main']['nodes']['1']['field_top_image']);

in the tpl.php after inspecting $page object with devel module enabled and dsm($page) added to my .tpl.php

mpp’s picture

The following is a similar error that can be reproduced with apachesolr in combination with ds_search and entity fields (e.g. references or field collections):
"EntityMalformedException: Missing bundle property on entity of type node. in entity_extract_ids() (line 7734 of includes/common.inc)"

When a node with entity fields is deleted in Drupal but still exists in SOLR, ds_search will try to render it and fails.

A quick fix would be to skip processing search results if they no longer exist in Drupal:

/**
* Process results on behalf of Apache Solr.
*/
function ds_search_process_results($results) {

$processed_results = array();

if (is_array($results) && !empty($results)) {
foreach ($results as $result) {

$load = entity_load($result['fields']['entity_type'], array($result['fields']['entity_id']));
$entity = reset($load);
+ if (empty($entity)) continue;

ryanc’s picture

I was seeing this error when using VBO and Workbench Moderation. It was fixed by https://www.drupal.org/node/1787214#comment-7616287

gaurav.pahuja’s picture

#13 working for me :)

I was not sure about the corrupted content type so modified the query accordingly.

davidneedham’s picture

For me certain nodes and search generated this error. I fixed it using suggestions from @kenorb in #22. I downloaded the Taxonomy Orphanage module, ran it, and everything worked again. Thanks kenorb!

Poindexterous’s picture

I ran into this error with a site I had to diagnose, this error was preventing the site from indexing during cron. Sadly none of the above solved my problem but it certainly helped me get on the right track. My issue was caused by multiple bad nodes, some were content type orphans, but one seems to be corrupted in some way and it even prevented Taxonomy Orphanage from executing! I wound up creating a view to filter out nodes where the content type was null, but the one remaining corrupted node remained elusive.

I'd like to provide a link that helped me when Taxonomy Orphanage failed to run:

http://tappetyclick.com/blog/2013/01/14/how-find-bad-node-makes-search-i...

This suggestion hacks core just a bit (temporarily) to use watchdog to catch the NID of the entity that cron is processing right before it breaks down. This is the only thing that worked identify the final rogue nid that was throwing this error and causing indexing to halt.

I know that hacking core is a no-no, and I did this on a local environment then reverted the files back when finished (now that I have all the bad NID ids I can go to prod and delete them). However I wasn't able to find any other way to ID the one node that was proving to be the trouble maker. I'm not quite familiar enough with programing to figure out a more endorsed solution, but someone else out there might. I'm not sure if it's possible to do but it would be helpful if errors like "EntityMalformedException: Missing bundle property on entity of type node. in entity_extract_ids() " may be changed in the future to include a NID or entity ID.

jfcolomer’s picture

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

kenorb’s picture

webjazznl’s picture

Alright, reading this post there seems to be a myriad of ways to run into this problem. I got the same error in a different line number (because of advancing Drupal versions I suppose)

Missing bundle property on entity of type node. in entity_extract_ids() (line 7729 )

In my case it occured on an existing view that used the Search API. At some point during development (involving creation and deletion of nodes) the index became misaligned it seems. Clearing all the indexes i had running in Search API did the trick!

So also clear them indexes when running into this one folks!

As a side note: The strange part was that earlier backups of my database made with Backup and Migrate, that were working fine earlier on, started showing the same problem. So apart from the cache, Backup and Migrate skips the index tables too it seems...

Tomáš Fejfar’s picture

In my case it was caused by using Accordion Views module and having Display Suite display mode set. When I set it to Fields it disappeared.

oknate’s picture

I had this problem when nodes would be deleted by the feeds module. For some reason Drupal doesn't vet the nodes before trying to load them. I found a work around by using hook_apachesolr_search_page_alter and removing the offending nodes, if they are no longer on the node table, as well as pinging the apachesolr module to remove them.

Here's the fix:

/**
 * Implements hook_apachesolr_search_page_alter(&$build, $search_page).
 * if an entity of type node is in the search index, it breaks entity_extract_ids
 * this is a fix to remove the offending node from the results, so the page 
 * doesn't call entity_extact_ids on it, and marks the node for removal from 
 * apachesolr search results
 * 
 * note: the weight of this module must be lower that other modules that might pass the
 * entities to entities_extract_ids
 * 
 */
function mymodule_apachesolr_search_page_alter(&$build, $search_page) {
  
  $results = $build['search_results']['#results'];
  foreach($results as $key => $result_item) {
    if($result_item['entity_type'] == 'node') {
      $nid = $result_item['fields']['entity_id'];
       $exists = (int) db_query("SELECT nid from node where nid = :nid", array(":nid" => $nid))->fetchField();
       if(!$exists) {
         $env_id = $build['search_form']["#search_page"]['env_id'];
         apachesolr_remove_entity($env_id, 'node', $nid);
         unset($build['search_results']['#results'][$key]);
         
       }
    }
  }
}
matthieu_collet’s picture

@oknate, I've got the same problem and putted your function in a custom module

but when is it activated ? at indexation ? it doesn't fix the problem for the moment in my case

rangi500’s picture

Putting a debug_backtrace() before the exception is thrown (as recommended in #13 above) helped me track down this problem. A custom module was getting a node with menu_get_object() and passing this into field_get_items(). When the block was being displayed on the "Add node" form, $node was empty and this exception was being thrown. So I added a check to make sure $node is not null before calling field_get_items().

leopathu’s picture

Hi,
I have faced the same problem, while programmatically create a node. But i have solved the problem. In my case i didn't mention the node type. I think, that the problem in this case for term.

marcoka’s picture

i had this problem when i used views_insert and had a taxonomy field there. if i remove it it works
https://www.drupal.org/project/insert_view

colorfield’s picture

This issue, related to the taxonomy_term bundle in my case, caused a crash of the search index. First, I tried to apply the patch mentioned in this related post EntityMalformedException: Missing bundle property on entity of type taxonomy_term but rolled back the change.
Here is the stack trace after running drush search-reindex --immediate --verbose

#0 /var/www/my_site/www/includes/common.inc(8024): entity_extract_ids('taxonomy_term', false)
#1 /var/www/my_site/www/sites/all/modules/custom/common_tools/common_tools.module(547): entity_uri('taxonomy_term', false)
#2 /var/www/my_site/www/modules/field/field.default.inc(210): common_tools_field_formatter_view('node', Object(stdClass),
Array, Array, 'und', Array, Array)
#3 /var/www/my_site/www/modules/field/field.attach.inc(209): field_default_view('node', Object(stdClass), Array, Array, 'und',
Array, 'search_index', NULL)
#4 /var/www/my_site/www/modules/field/field.attach.inc(385): _field_invoke('view', 'node', Object(stdClass), 'search_index',
NULL, Array)
#5 /var/www/my_site/www/modules/field/field.attach.inc(1228): _field_invoke_default('view', 'node', Object(stdClass),
'search_index', NULL, Array)
#6 /var/www/my_site/www/modules/node/node.module(1414): field_attach_view('node', Object(stdClass), 'search_index', 'fr')
#7 /var/www/my_site/www/modules/node/node.module(1335): node_build_content(Object(stdClass), 'search_index', 'fr')
#8 /var/www/my_site/www/modules/node/node.module(2792): node_view(Object(stdClass), 'search_index')
#9 /var/www/my_site/www/modules/node/node.module(2774): _node_index_node(Object(stdClass))
#10 [internal function]: node_update_index()
#11 /var/www/my_site/www/includes/module.inc(866): call_user_func_array('node_update_ind...', Array)
#12 [internal function]: module_invoke('node', 'update_index')

I figured out that deleting the nodes with a status of 0 solved the issue and the search index is now working again. Some missing taxonomy_term references were (maybe) still used in these unpublished nodes? Will maybe ring a bell.

jbd44’s picture

For me, this error was thrown by my implementation of hook_node_info. Changing the base attribute from 'my_module' to 'node_content' fixed the problem.

jazzitup’s picture

Actually the following comment helped me a lot to debug my own issue that led me to this: #1277376-49: EntityMalformedException: Missing bundle property on entity of type node. in entity_extract_ids() (line 7390

Within my custom module I had this code:

function MODULENAME_preprocess_html(&$variables) {
  if (!$variables['is_front'] && arg(0) == 'node') {
    $node = node_load(arg(1));
    $results = field_view_field('node', $node, 'field_custom_category', array('default'));
    ...

It has nothing to do with Drupal - it is NOT Drupal's fault. It's a human error. In other words, field_view_field() has been triggered even on node/add pages, so I needed to change the code into something more meaningful like this:

function MODULENAME_preprocess_html(&$variables) {
  if (!$variables['is_front'] && arg(0) == 'node' && is_numeric(arg(1)) && arg(2) != 'edit') {
    $node = node_load(arg(1));
    $results = field_view_field('node', $node, 'field_custom_category', array('default'));
    ...

That resolved my issue completely. I hope it will help someone to debug his similar issue quickly.

meecect’s picture

Similar to #13, it turned out to be an entry in the node table (and the revisions table) that didn't have corresponding entries in other tables, and also was of a content type that we no longer had anymore.

Luckily for us, the entry stuck out like a sore thumb just looking at the node table, so we found it easily.

We are still ot sure what caused the problem to just appear, but we think it was due to a number of factors during our development process. For example, we upgraded some modules that ran some schema alters, which could have revealed the problem, or it could have been that we had just configured solr and varnish.

So, we _think_, those changes contributed to the problem. So, we changea taxonomy field definition, and the solr knows it needs to index all the nodes that term is on, so it loads all nodes, but then encounters the issue with a 'bogus' node in the node table that has no corresponding entries in all the associated tables.

In a way, this is the reverse situation of the 'taxonomy orphanage' problem. Although many people have solved this problem, or a very similar symptomatic problem with that module, our problem was different. In taxonomy orphanage, the problem was nodes that refer to taxonomy terms that no longer exist, and in this case, it was nodes that exist that don't have the rest of their data.

Or something like that.

khosman’s picture

Happened here when I set a view (as in "the views module" versus a content type's view mode) to show "Display Suite" with a display view (as opposed to fields); setting it to "Content" instead of "Display Suite" made the problem go away.

jason1234’s picture

I am trying to add the comment to the content type's page panel, I get the following error:

  • An AJAX HTTP error occurred.
  • HTTP Result Code: 500
  • Debugging information follows.
  • Path: /drupal/en/panels/ajax/editor/select-content/panel_context%3Anode_edit%3A%3Anode_edit_panel_context_2%3A%3A%3A%3A/contentmain/comment?
  • type_name=comment_reply_form&subtype_name=comment_reply_form
  • StatusText: Service unavailable (with message)
  • ResponseText: EntityMalformedException: Missing bundle property on entity of type node. in entity_extract_ids() (line 7844 of /home/content/70/8340170/html/develNew/drupal/includes/common.inc).



Attempt 1

  • The first thing that I tried was to find an orphaned field or node.
  • Searching through the database, there didn't seem to be one.
  • I compared the 'nid' column from 'node' table to the 'nid' column in the 'node_revision' table.
  • Resource: https://www.drupal.org/node/1778572



Attempt 2

  • In the file '\includes\common.inc' add the following patch:
    • function entity_extract_ids($entity_type, $entity) { ...
    • - if (!empty($info['entity keys']['bundle'])) {
    • + if (!empty($entity->{$info['entity keys']['bundle']})) {


  • Resource: http://drupal.stackexchange.com/questions/85478/entitymalformedexception...
  • This removed the error but then produced a new one:
    • 'Error Fatal error: Unsupported operand types'


  • To solve that error, in '/modules/node/node.module' line 1342, add added the following patch:
    • - $build += array(
    • + $build[] = array(


  • Resource: https://www.drupal.org/node/2181367
  • It removed the error, but then produced the following error (An AJAX HTTP error occurred in panel content editor):
    • An AJAX HTTP error occurred.
    • HTTP Result Code: 200
    • Debugging information follows.
    • Path: (URL path of request)
    • StatusText: OK
    • ResponseText: (A huge jQuery output...)


  • This final error has me at a loss.
HansKuiters’s picture

Using debug_backtrace() from #13 helped me a lot. I was importing flexifield data from D6 database to field collections in D7 database. Because D6 was still the live site, I imported nodes from D6 that were not yet available on new D7. That throwed the error. I now added a check for the node to be available on D7.

TheDelta’s picture

I used the devel module and ddebug_trace() (https://api.drupal.org/api/devel/devel.module/function/ddebug_backtrace/7) to find the issue. (kudus to #13)

It took a bit but it was caused by my custom written field in Display Suite, which I was copied for another content type and it was referencing the wrong field.

Nikrene’s picture

I had the same issue after deleting one taxonomy term and editing the title and url of another term. I was happy to see though that Clear all caches was the solution for me!

jkdev’s picture

Use DRUSH with -d

It helps a lot!!

In my case it was the module commerce_auction.
Backtrace:

Calling hook drush_core_php_script [0.41 sec, 28.59 MB]                                                                                                                                          [debug]
WD file: The file public://a/a.jpg was not deleted, because it does not exist. [0.44 sec, 29.83 MB]                                                                                  [notice]
WD node: EntityMalformedException: Missing bundle property on entity of type commerce_product. in entity_extract_ids() (line 7880 of /usr/share/nginx/html/d7dev/includes/common.inc). [0.47[error]
sec, 31 MB]
WD commerce_product: EntityMalformedException: Missing bundle property on entity of type commerce_product. in entity_extract_ids() (line 7880 of                                             [error]
/usr/share/nginx/html/d7dev/includes/common.inc). [0.48 sec, 30.99 MB]
exception 'EntityMalformedException' with message 'Missing bundle property on entity of type commerce_product.' in /usr/share/nginx/html/d7dev/includes/common.inc:7880                     [error]
Stack trace:
#0 /usr/share/nginx/html/d7dev/modules/field/field.multilingual.inc(268): entity_extract_ids('commerce_produc...', false)
#1 /usr/share/nginx/html/d7dev/modules/field/field.module(926): field_language('commerce_produc...', false, 'commerce_price', NULL)
#2 /usr/share/nginx/html/d7dev/sites/all/modules/commerce_auction/commerce_auction.module(262): field_get_items('commerce_produc...', false, 'commerce_price')
#3 [internal function]: commerce_auction_node_presave(Object(stdClass))
#4 /usr/share/nginx/html/d7dev/includes/module.inc(951): call_user_func_array('commerce_auctio...', Array)
#5 /usr/share/nginx/html/d7dev/modules/node/node.module(1106): module_invoke_all('node_presave', Object(stdClass))
#6 /usr/share/nginx/html/d7dev/sites/all/modules/entity/entity.module(286): node_save(Object(stdClass))
#7 /usr/share/nginx/html/d7dev/sites/all/modules/commerce/modules/product_reference/commerce_product_reference.module(299): entity_save('node', Object(stdClass))
#8 [internal function]: commerce_product_reference_commerce_product_delete(Object(stdClass))
#9 /usr/share/nginx/html/d7dev/includes/module.inc(951): call_user_func_array('commerce_produc...', Array)
#10 /usr/share/nginx/html/d7dev/sites/all/modules/commerce/includes/commerce.controller.inc(98): module_invoke_all('commerce_produc...', Object(stdClass))
#11 /usr/share/nginx/html/d7dev/sites/all/modules/commerce/includes/commerce.controller.inc(145): DrupalCommerceEntityController->invoke('delete', Object(stdClass))
#12 /usr/share/nginx/html/d7dev/sites/all/modules/commerce/modules/product/includes/commerce_product.controller.inc(162): DrupalCommerceEntityController->delete(Array, NULL)
#13 /usr/share/nginx/html/d7dev/sites/all/modules/commerce/modules/product/commerce_product.module(588): CommerceProductEntityController->delete(Array)
#14 /usr/share/nginx/html/d7dev/del_all_prods.php(7): commerce_product_delete_multiple(Array)
#15 /root/.composer/vendor/drush/drush/commands/core/core.drush.inc(1117): include('/usr/share/ngin...')
#16 [internal function]: drush_core_php_script('del_all_prods.p...')
#17 /root/.composer/vendor/drush/drush/includes/command.inc(368): call_user_func_array('drush_core_php_...', Array)
#18 /root/.composer/vendor/drush/drush/includes/command.inc(219): _drush_invoke_hooks(Array, Array)
#19 [internal function]: drush_command('del_all_prods.p...')
#20 /root/.composer/vendor/drush/drush/includes/command.inc(187): call_user_func_array('drush_command', Array)
#21 /root/.composer/vendor/drush/drush/lib/Drush/Boot/BaseBoot.php(62): drush_dispatch(Array)
#22 /root/.composer/vendor/drush/drush/drush.php(70): Drush\Boot\BaseBoot->bootstrap_and_dispatch()
#23 /root/.composer/vendor/drush/drush/drush.php(11): drush_main()
#24 {main} [0.48 sec, 30.99 MB]
Command dispatch complete [0.48 sec, 30.86 MB]                                                                                                                                                  [notice]
 Timer  Cum (sec)  Count  Avg (msec) 
 page   0.375      1      374.98

This is the code in the mentioned module:

/**
 * Implements hook_node_presave().
 */
function commerce_auction_node_presave($node) {
  $types = variable_get('commerce_auction_display_types', array());
  if (in_array($node->type, $types) !== FALSE) {
    $product_reference = field_get_items('node', $node, 'field_product');
    $product_reference = $product_reference[0];
    $product = commerce_product_load($product_reference['product_id']);
    $price = field_get_items('commerce_product', $product, 'commerce_price');
    $node->auction_starting_price[LANGUAGE_NONE][0]['amount'] = $price[0]['amount'];
    $node->auction_starting_price[LANGUAGE_NONE][0]['currency_code'] = $price[0]['currency_code'];
  }
}

I guess the purpose of it, is to set the field 'starting price' to what ever price in the product.

The problem is that the code assumes that product loaded successfully, and as you can see clearly above,
$product = commerce_product_load($product_reference['product_id']);
simply return false.

To get around it, I hacked the module, adding necessary checks.

/**
 * Implements hook_node_presave().
 */
function commerce_auction_node_presave($node) {
  $types = variable_get('commerce_auction_display_types', array());
  if (in_array($node->type, $types) !== FALSE) {
    $product_reference = field_get_items('node', $node, 'field_product');
    if ($product_reference){
      $product_reference = $product_reference[0];
      $product = commerce_product_load($product_reference['product_id']);
      if ($product){
        $price = field_get_items('commerce_product', $product, 'commerce_price');
        $node->auction_starting_price[LANGUAGE_NONE][0]['amount'] = $price[0]['amount'];
        $node->auction_starting_price[LANGUAGE_NONE][0]['currency_code'] = $price[0]['currency_code'];
      }
    }
  }
}

Hope it will help someone in the future.

leisurman’s picture

How can I use the php query from #13?
Should I place this in a module or add the code right to a page using php input format,
Oe should I create a View and add it in using the php filter?

leisurman’s picture

I got rid of this error by deleting all nodes that had not cck and no title. Ghost nodes. I had 80.
like this
DELETE FROM `databasename`.`node` WHERE type = '';

kenorb’s picture

To troubleshoot EntityMalformedException, check: How to debug EntityMalformedException at DO?

GaneshKumar’s picture

#4 works for me.

arunkumar53’s picture

Same problem here, my search is showing old data,while running a cron it showing sucessfully cron ran but in error log it showing
Missing bundle property on entity of type node. in entity_extract_ids()

I tried following options #4,#13, Taxnomy Orphange nothing is working.

Kindly guide me to close this

MatthijsG’s picture

@arunkumar53 did you try #66?

It helped me; there was an orphaned node (not tag!) in the node-table.

ponies’s picture

Thanks, Tomáš. The views accordion / display suite conflict was the magic bit that solved our issue.

Nikolay Borisov’s picture

this may happen if you try to load an Entity with an id that is not really an id of an entity.

Per say: node_load('bananas');
or
entity_load('user', 'Peter the anteater'); // here it expects an id again

Hope it helps someone,
cheers!

Mfeldman7282’s picture

I can't seem to get any errors to display using debug_backtrace(); Where did you see the errors after running the Cron Job?

Anonymous’s picture

Thank You flesheater, #72

That was my case, I was sending string not int as an ID

javierlandini’s picture

In my case, I was trying to create some terms programatically with Entity API. The vocabulary of the terms has a term reference field to reference fields from a different vocabulary.

I was doing something like:

      $v_country_groups = taxonomy_vocabulary_machine_name_load('country_groups');
      $data = array(
        'name' => 'My new term',
        'vid' => $v_country_groups->vid,
      );
      
      $country_group_term = entity_create('taxonomy_term', $data);
      $wrapper = entity_metadata_wrapper('taxonomy_term', $country_group_term);
      $wrapper->field_country_code = $countries_tids;
      $wrapper->save();

where $countries_tids is an array of tids that I build previously with the list of terms from the other vocabulary that I need to reference from my new term.

This was throwing this error: EntityMalformedException: Missing bundle property on entity of type taxonomy_term. in entity_extract_ids() (line 7908 of /var/www/wwe/includes/common.inc).

Surprisingly, if I didn't set field_country_code, the above code worked well and created the new term (obviously, without that field set in the newly created term).

And what I finally did to make it work was adding the vocabulary machine name to the data array, so my final code is like this:

      $v_country_groups = taxonomy_vocabulary_machine_name_load('country_groups');
      $data = array(
        'name' => 'My new term',
        'vid' => $v_country_groups->vid,
        'vocabulary_machine_name' => $v_country_groups->machine_name,
      );
      
      $country_group_term = entity_create('taxonomy_term', $data);
      $wrapper = entity_metadata_wrapper('taxonomy_term', $country_group_term);
      $wrapper->field_country_code = $countries_tids;
      $wrapper->save();

Hope this helps someone.

trong.nguyen.tcec’s picture

If you use module Colorbox field formatter and Error happen on viewing node (the node has field(s) with entity reference) try to disable module for test.

jurgenhaas’s picture

@trong.nguyen.tcec, why are you saying this? Have you got any evidence, that colorbox_field_formatter has anything to do with this? You also reported #2870940: EntityMalformedException: Missing bundle property on entity of type node. in entity_extract_ids() (line 7929 of /includes/common.inc) and to this point, I can't see any reason why that module should be responsible for that error.

So, your recommendation to disable it (in bold!) is not justified as far as I can tell.

If there is an issue with colorbox_field_formatter, of course we are going to fix that. But please do not recommend to disable it. It's a module being used by over 2.000 sites and by that a fairly popular module. Your advise may be perceived as misleading by some.

rhemeleers’s picture

A feedback:
The error appeared after I tried use the "CONVERT" module to change the content type for a node. I deleted the page manually and the problems was gone

yurg’s picture

Seems to be unresolved so far so here's (not)my 2c: http://www.staciearellano.com/bad-node-bad-node-whatcha-gonna-do/ link describes a workaround, which corresponds to some other comments in the thread.

Clemence.Blazy’s picture

Thanks a lot to #13 who saved my life. Just put the sql query in MyPHPadmin, and found the faulty content, delete it, and everything went back in order. No more errors or warnings, and cron back to work. Still today in 2017.

Kris77’s picture

I have this problem when save a node. In my content type there is a a email field with field validate for unique value.

The problem does not always present, but when it happens all fields of the content type are filled but is not assigned a nid and vid to the node.

The url is also created(example url/123456), but if search in node and node_revision table for that url there is nothing.

So, if I trie to create another node with same field value and change only email field value the node is created.

With #13 i have no result because there isn't nid or vid.

Thank you so much.

ayandyan’s picture

Took me an hour to find the cause of the issue. Mine is due to the Taxonomy Term Status module where for some reason it clears the vocabulary machine name of the entity in common.inc.

It's not really an absolute fix, but I unchecked the "Enable term status" setting for the module (/admin/config/system/termstatus) to get going.

othermachines’s picture

Just thought I'd note that I was getting this error on cron, and it was a result of an entry stuck in the core queue table from when I was setting up bulk email functionality using Views Bulk Operations. The error itself may have been due to a malformed token, as the entity type being processed was actually user, not node.

Anyway, cleaning out the queue table solved it.

The error:

EntityMalformedException: Missing bundle property on entity of type node. in entity_extract_ids() (line 7936 of D:\---\includes\common.inc).
ykoech’s picture

#13 worked perfectly for me and solved other indexing errors. Thank you.

trong.nguyen.tcec’s picture

If you use module "xmlsitemap_node", please use this path on file xmlsitemap_node.module:

/**
 * Implements hook_cron().
 *
 * Process nodes that need to be added to or updated in the {xmlsitemap} table.
 */
function xmlsitemap_node_cron() {
  $limit = xmlsitemap_var('batch_limit');

  // Process nodes that have been queued in hook_node_update().
  $queue = DrupalQueue::get('xmlsitemap_node');
  while ($limit > 0 && $item = $queue->claimItem()) {
    $limit--;
    try {
      $node = node_load($item->data);
  +    if(!$node){ // $node = false.
  +       continue;
  +    }
      $link = xmlsitemap_node_create_link($node);
      xmlsitemap_link_save($link, array($link['type'] => $node));
      $queue->deleteItem($item);
    }
    catch (Exception $e) {
      // In case of exception log it and leave the item in the queue
      // to be processed again later.
      watchdog_exception('xmlsitemap_node', $e);
    }
  }

  // Add nodes that are missing from the {xmlsitemap} table.
  // This catches nodes that were created prior to this module being enabled.
  xmlsitemap_node_xmlsitemap_index_links($limit);
}
Kris77’s picture

I noticed that, in my case, the error appears when the node id does not match the revision id.
Can someone give me a solution?

Thanks so much.

lubwn’s picture

Anyone coming to this issue - it was related to Feeds module in my case. But since I had almost finished site and did not want to re-build it from scratch, I just decided to deal with the problem.

So my error was:

EntityMalformedException: Missing bundle property on entity of type commerce_product. in entity_extract_ids() (riadok 7948 z /var/www/clients/client1/web30/web/includes/common.inc).

So it was related to "commerce_product" entity.

Solution:

Find this table in phpmyadmin and set autoincrement value to very high number - like 10000 or so.

What caused this problem:

I think I imported a LOT of nodes and commerce products via feeds, and deleted them afterwards. But Drupal did not cleaned all the things up and left some orphaned rows somewhere. Maybe they are entities, maybe they are nodes.. I have no idea. But it works nicely now.

So just find a table and increase autoincrement. It does not "solve" the problem in the proper way, but rather hide it for good.

JasonSafro’s picture

I got the same error, tied to the OG module. There were leftover rows on og_membership for nodes that were deleted. See https://www.drupal.org/project/og/issues/2900273.

Patch #14 worked for me.

wasid’s picture

I faced the issue in 2023 after changing a term name which was assigned to a node. without deleting or backing up anything I just reassigned the changed term to that same node and the problem was fixed.