Throws "EntityMalformedException: Missing bundle property on entity of type file. in entity_extract_ids() (line 7389 of /Applications/MAMP/htdocs/csr/includes/common.inc)."

Migrate back to 7.7 and it works fine.

Comments

xjm’s picture

Hi @blackclover,

At what point during the upgrade do you get this message? Also, could you provide a backtrace of the error message? (One way to easily add backtraces is with the devel module.)

marcingy’s picture

This issue was introduced by #1067750: Let Field API fail in a tale-telling way on invalid $entity which results in sites rather than ignoring a broken entity throwing an exception. Maybe the original issue needs to be relooked at and instead the errors should be watchdoged. The errors are useful but it doesn't leave the site in graceful place.

blackclover’s picture

I get the error when I navigate to the URL for the site after the upgrade and I get the same error when I try to navigate to any page on the site. I have devel running but the site is basically DOA after the error.

blackclover’s picture

Also tried it on different site (for my daily beating) and got the same error.

xjm’s picture

Before you attempt the upgrade, you could configure devel to display backtraces. This setting is at admin/config/development/devel under Error handler. I think that should output a backtrace for you when it renders the error.

If the backtrace doesn't work, another way to see what the bad entity is might be to add a bit of debugging code in entity_extract_ids() in includes/common.inc. (This will not solve the problem, only give more information about it.) You could try changing this:

  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']} === '') {

to this:

  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']} === '') {
      die(print_r($entity, TRUE));

That should show us all the details of the file entity.

Basically, something on your site has saved a malformed file entity, so presumably when your site tries to rebuild the cache after the upgrade, it is failing. My hunch is that the entity might be altered by a contributed module.

xjm’s picture

Starminder’s picture

subscribe

somatics’s picture

Same problem, on upgrade from 7.7 to 7.8 today.

It's preventing us from rebuilding our permissions, which we urgently need to do. When I run Rebuild Permissions, it fails with the following error:

"An AJAX HTTP error occurred. HTTP Result Code: 500 Debugging information follows. Path: /batch?id=39158&op=do StatusText: Service unavailable (with message) ResponseText: EntityMalformedException: Missing bundle property on entity of type node. in entity_extract_ids() (line 7389 of /pathtodrupalfolder/includes/common.inc)."

xjm’s picture

Again, are those of you getting this error using the media module? See #1266620: Missing bundle property on entity of type file error.

A temporary workaround might be to apply http://drupal.org/files/issues/drupal_8_entity_malformed.patch with the -R flag.

somatics’s picture

I do not have the Media module installed, nor the File Entity module.

Is it possible that even the instances of this bug being attributed to the Media module or the File Entity module are about Drupal core or some other component?

effulgentsia’s picture

@somatics: Your error is different: "Missing bundle property on entity of type node". Please open a new issue for that, and link to it from here. You probably have some other contrib module that's responsible for you having nodes without a type, so in your new issue, please list all the contrib modules you're using.

I'm closing this issue as a duplicate of #1266620: Missing bundle property on entity of type file error. If someone gets the message of "Missing bundle property on entity of type file" who isn't using the Media module, then please re-open this issue.

effulgentsia’s picture

Status: Active » Closed (duplicate)
somatics’s picture

Thanks for this information, I really appreciate your clarifications, getting me pointed in the right direction to correct this matter.

Could you please tell me: Are you saying that if there are nodes of a node type that was created by an old module that is no longer used, this will cause this problem? For example, we have some nodes that were created by an old, now-abandoned module called bookreview or something like that. We have been planning to migrate those nodes over to become another new custom node type.

It sounds like what you're saying is as long as these nodes are in the system with effectively no node type, Drupal 7.8 forward will continue to have this problem.

effulgentsia’s picture

It sounds like what you're saying is as long as these nodes are in the system with effectively no node type, Drupal 7.8 forward will continue to have this problem.

If the node type for those nodes is NULL or an empty string, then yes. If the node type is a string that doesn't correspond to one of the ones on the admin/structure/types page, then I'm not sure yet if that would cause this problem, a different one, or be okay.

xjm’s picture

Somatics:

  1. #980740: Drupal 7 (Sheetnode) includes the missing bundle error for a node entity, if you are using the Sheetnode module.
  2. Otherwise, open a new issue for your error message. In that new issue, include the sorts of debugging details I ask for in #5: specifically, what module is creating the malformed entities. If it is a contrib module, file the issue against that contrib module.
  3. There are several workarounds you can try for now:
blackclover’s picture

Backtrace was of no help but I did what you suggested in common.inc and it turned out to be a bunch of uploaded images in the file_managed table. type was missing so I added "image" as the type and site started working again. Thanks for your help.

Chris.Carrigan’s picture

This isssue has my site down as no-one can post new content. I need to regress out of this very quickly - for a non developer can you please explain the above or point me to the how to regress documentation for it.

This is quite a major issue I suspect for many people. As it won't neceseraly show in testing and is related to quality in add on modules. My problem is context specific for example and did not show in initial testing. 7.8 will break many sites if this is not regressed out.

xjm’s picture

#17: See #15 for steps to work around the problem. Or, roll back to 7.7 until the issue is resolved in whatever contributed module is causing the error.

If it is urgent or time-sensitive, you should probably consider paid consulting. The drupal issue queues are not really good for that kind of support.

cartagena’s picture

I got the same error message when I upgraded on my local site. I did as suggested by #16 and when I added the types for some image, audio and default files all was fine. I do not have media enabled on this site. My other site, which uses media, did not get the error message. If there is anything else I can provide to help resolve the issue, I will do that. I'll also wait to move the upgrade to my live site...Thanks again to all who are working on this issue.

Chris.Carrigan’s picture

Update on this - I regressed to 7.7