[EDIT: If I have put this in the wrong place or followed the wrong procedure, let me know.]

A user on my website recently tried to upload 106 files at once via 'add content'. The files themselves uploaded fine, but when she clicked 'save' the following error occurred:

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

I could not recreate the problem on my end, and it doesn't have to do with the php values of upload_max_size or post_max_size.

Having descended into the code and checked a number of maddeningly similar-but-not-the-same questions online, I know the following:

The relevant piece of code is:

<?php
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)));
    } 
?>

So I think for some reason the new data files are not being assigned a bundle (even though that should be set to 'raw_data' by default).

In other places online, people mentioned disabling and re-enabling certain modules (such as the field permissions module), none of which are installed on my site.

Others mentioned going into the mySQL database and manually including bundles. But the uploads were not saved, so that won't work.

I am not sure how to check the actual code of 'add content', which is obviously what triggered the error. Nor do I know how to trace the error.

Does anyone have any suggestions or ideas? I understand that this is a murky problem and I have not presented much of use.

The site is very bare-bones, and some (possibly relevant?) enabled modules are:
Access Control
Administration
Chaos tools
Date/time
Features
Fields
node_clone
prepopulate
Rules
Views

(Each of them are the latest updated version for drupal 7.22.)

I am a total newbie, so please have patience with me. Thanks!

Comments

john_b’s picture

Speculating on the cause, the server was overstretched and Drupal attempted to save the node to the database but the data was incompletely saved. The trying to resave it, the code found it was trying to update a 'malformed entity' and baled out with that error. You might look at this comment http://drupal.org/node/1778572#comment-6891428 and check for the possibility that the malformed node (which is a kind of entity: the entity bundle is the content type) is not still in the database. Beyond that I think you just need to work out how to set up the server such that writes to the database by Drupal do not get corrupted just because someone Drupal is attempting to write to the database at the same time as someone is hammering the hard disks or consuming a lot of RAM by some very demanding file uploads.

It is a question of matching hosting resources, quality and setup to the level of demands your users will place upon it. Drupal database usage involves heavy IO and is by no means unusual to see corrupt data in the database when the server resources are insufficient to handle database writes in an error-free way.

Digit Professionals specialising in Drupal, WordPress & CiviCRM support for publishers in non-profit and related sectors

Bruno Vincent’s picture

I'm a worse newbie that you...

But the settings here once stopped me uploading a large SQL file with backup_migrate

Check your settings here:

admin/config/media/file-system

Also gzip and zip file conflicts caused problems...but again because I was going from locahost to live

Masterfool’s picture

I don't *think* the file-system set-up is a problem, but then I am mystified, so...

There don't seem to be any malformed nodes in the database. node_access, for instance, has the exact same number of rows as node. node_revision has some extras, but I hope that is to be expected, given its title. It doesn't look like any of the files she tried to upload have made it in, in any form.

I feel it must be significant that the problem is not occurring on my end, even when I duplicate her uploads almost exactly (though I haven't seen her exact method).

I will look into setting up the server better.

Masterfool’s picture

Thanks for your comments, guys, I found that very helpful. The problem is still persisting (and I still can't duplicate it on my end, oddly enough), and I am looking into your suggestions.

Masterfool’s picture

Turns out the error was probably due to the fact that the user was uploading from a wireless connection, and the server just timed out on her. Thus, information was not transmitted to the database and it found 'NULL' when it looked for the bundle properties.

Increasing the time limit before server time-out seems to have done the job as a bandaid solution, though obviously not ideal. Thanks for the help!

Masterfool’s picture

Actually, the solution to my problem was much simpler than any of our speculations. See the post I made about it:

https://drupal.org/node/2035167

(The solution is my first comment.)