When I try to go to...
admin/content/media
admin/content/file

I get the following error...
EntityMalformedException: Missing bundle property on entity of type file. in entity_extract_ids() (line 7500

I've also gotten this on "admin/content/file"...
EntityMalformedException: Missing bundle property on entity of type file. in entity_extract_ids() (line 7501 of /opt/drupal-7.12/includes/common.inc).

It's rendering those pages unusable.

Related discussions
#1268378: Empty file type causes exceptions in Drupal 7.8
#1330882: EntityMalformedException : Missing bundle property on entity - after uninstalling modules providing reference fields
#1277376: EntityMalformedException: Missing bundle property on entity of type node. in entity_extract_ids() (line 7390
#1323244: EntityMalformedException: Missing bundle property after updating to OG 7.1.2
#1426820: Fix Notices and EntityMalformedException if FID is not in the file_managed database table

Comments

bryancasler’s picture

Issue summary: View changes

x

bryancasler’s picture

Issue summary: View changes

c

bryancasler’s picture

Turned out to be this record in the "file_managed" table missing its "filemime" field

http://www.diigo.com/item/image/1ks4o/19pr?size=o

Not sure how this happened, could this be a part of another bug?

jjclint’s picture

I'm getting the same error on one of my test sites how did you track it down and solve it?

bryancasler’s picture

I had to look directly in the database in the "file_managed" table. Then look in every column and see if an entry is blank. On top of the record shown in the screenshot I found another record that was missing info in a different column. I had to fill in the blanks, literally, to get everything working again.

dmblackwell’s picture

Version: 7.x-2.x-dev » 7.x-1.0-beta3

I created this error after working through the buildamodule.com exercise intended to produce a different error from the Media 7.x-1.0-beta3 that used Styles. The problem was indeed some mangled tuples in the file_managed table, updating to the current version of Media got rid of the fatal error, but I still could not delete the damaged records. I appear to have resolved it by clearing the table and then importing all the existing media files again... but it was a practice stack, so I really wasn't worried about breaking it. I suspect it is a previously well known problem with new symptoms related to a recent update.

tsvenson’s picture

Version: 7.x-1.0-beta3 » 7.x-2.x-dev

@dmblackwell Please don't change version to an older version. Instead mention in the comment text what version you experienced the same issue in.

Also, since the beta3 version you are using there have been several new 1.x versions released, including RCs so please try with those first, plus eventually the dev version to exclude it hasn't been fixed already.

dmblackwell’s picture

@tsvenson My apologies, I didn't realize I was changing the version for the thread, I only intended to indicate the version I was using. (I am kind of new here.)

My only salient point was that I received this error message, instead of the error message I was expecting to see, after deliberately reproducing a known bug using a specific earlier version of Media. This just implies that the specific error is dependent on something other than the bug.

tsvenson’s picture

@dmblackwell: No worries, did similar faults when I was new too. Welcome to Media.

Even though we do some backporting of bug fixes to 1.x from 2.x, they are still two separated branches. Thus, even if a bug exist in one of them, it doesn't necessarily also exist in the other as they do have a different feature set. Thus, first you really need to, in this case, make sure the problem is cropping up in the latest version of the 1.x code, which is the -dev, or at least in the latest tagged version which is RC3.

It is quite often different people working on different branches as well.

queenvictoria’s picture

Just as an aside I had a similar error with D7.10 and media 2.x-dev. I tried lots of things mentioned here and elsewhere and upgraded all modules (media 7.x-2.0-unstable3) and core (D7.12). Eventually I just recreated the View that was causing this error (exported from an identical install) and that cured it. No missing fields in tables. No D7.8. No patching core.

themic8’s picture

I have the same error on Drupal 7.12, File Entity 7.x-2.x-dev from Feb 21, 2012.

This error occurred when I was trying to access my content through the admin menu (using the admin menu module), clicking on "Content"

I disabled the module and I am able to see my content (no error). The admin menu looks different now, when I hover over content it doesn't show the types of content. There is no on hover action.

In my file_managed table there is still information. Nothing is blank as described above.

Pancho’s picture

Same bug here with all combinations of:
- file_entity 7.x-2.0-unstable3 (2012-Jan-12) resp. 7.x-2.0-dev (2012-Feb-21).
- media 7.x-2.0-unstable3 (2012-Jan-12) resp. 7.x-2.0-dev (2012-Mar-08).
both using the core file field or the deprecated media field.

7.x-1.x-dev (2012-Mar-08) works.

HongPong’s picture

Oh so glad I finally found this thread. Problem indeed was missing 'type' entries in files_managed table.

Scope out yr files_managed table and then try something like the following on for size. In my case, when the affected file field was messed up, i got the malformed bundle errors inside the Views UI editor for views trying the field, and untraceable 'unexpected errors' on Views with that happening.
TO FIX:

UPDATE file_managed set type = 'application' where filemime = 'application/pdf' OR filemime = 'application/msword' OR filemime = 'application/rtf';
UPDATE file_managed set type = 'audio' where filemime = 'audio/mpeg';
UPDATE file_managed set type = 'image' where filemime = 'image/jpeg' OR filemime = 'image/png' OR filemime = 'image/png' OR filemime= 'image/gif';

There should really be something error checking files_managed for this kind of thing! I'm not dead certain those are the right 'type' entries right now (i.e. where is the canonical rule for 'audio' etc) but hey it got me out of these damn errors!

moniuch’s picture

FWIW, I'm having this error as well, using 7.14/Media+FileEntity unstable6. In my case though the entity type claimed by the error message is always "taxonomy term". I looked into taxonomy_term_* tables and saw nothing to be suspicious about, all columns/fields nicely filled up. On my site there's just one vocabulary, but the terms use a custom media field (a logotype image), that's why I think the issue might be related to Media/FE.

Originally tried to uncomment the or'red test at line 7539:
|| $entity->{$info['entity keys']['bundle']} === ''
which did not help.

Now I have modified the patch http://drupal.org/files/common.inc-1277376-36.patch by adding:
|| $entity_type == 'taxonomy_term'
and will wait to see if the error is gone. The pesky thing about it is that:

  • the error is visible to anonymous users
  • the error occurs randomly - which makes debugging very difficult and slow. It's more likely to come out after in the morning, which - in case of that fresh site of mine - means: after some longer idle time.
  • at my site it always comes bundled with "headers already sent" error, which probably causes the error to appear to anonymous eyes
moniuch’s picture

Unfortunately, the error got even worse after the changes in#12.

Notice: Trying to get property of non-object in entity_extract_ids() (line 7546 of [......]/includes/common.inc).
Notice: Trying to get property of non-object in field_entity_dependencies() (line 75 of [......]/sites/all/modules/entity_dependency/entity_dependency.core.inc).
Warning: Invalid argument supplied for foreach() in field_entity_dependencies() (line 75 of [......]/sites/all/modules/entity_dependency/entity_dependency.core.inc).
Notice: Trying to get property of non-object in field_entity_dependencies() (line 75 of [......]/sites/all/modules/entity_dependency/entity_dependency.core.inc).
Warning: Invalid argument supplied for foreach() in field_entity_dependencies() (line 75 of [......]/sites/all/modules/entity_dependency/entity_dependency.core.inc).
Notice: Trying to get property of non-object in taxonomy_entity_dependencies() (line 57 of [......]/sites/all/modules/entity_dependency/entity_dependency.core.inc).
Notice: Undefined property: stdClass::$vocabulary_machine_name in entity_extract_ids() (line 7546 of [......]/includes/common.inc).
Warning: Cannot modify header information - headers already sent by (output started at [......]/includes/common.inc:2608) in drupal_send_headers() (line 1239 of [......]/includes/bootstrap.inc).
schnere’s picture

Thanks moniuch, the patch from #12 worked great!

ncuano’s picture

Hi, moniuch and schnere,

I just tried #12, as in:

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)));
      // SB: Could not edit some imported D6 fields
      // "EntityMalformedException: Missing bundle property on entity of type node. "
      if ($entity_type=='node') {
        $bundle = $entity_type;   // lets edit it anyway
        watchdog('common', '$entity->type=empty, assume entity_type=node. fyi info[entity keys][bundle]=@bundle', array('@bundle'=>$info['entity keys']['bundle']) );
        }
        else {
          throw new EntityMalformedException(t('Missing bundle property on entity of type @entity_type.', array('@entity_type' => $entity_type)));
        }
	}
    $bundle = $entity->{$info['entity keys']['bundle']};
  }

My ? = Where to add this line:

$entity_type == 'taxonomy_term'

Thank you!

mpgeek’s picture

Status: Active » Closed (works as designed)

I think we've veered of the path of troubleshooting Media ... the hacking going on in #12 through #15 is happening in Core (common.inc), so there is no gain here for Media. Plus, from the initial issue description, the URLs admin/content/media and admin/content/file indicate a switch from 1.x to 2.x, which requires a little elbow grease to work properly, i.e. more than just downloading 2.x over a 1.x install and expecting it to work.

The file_managed problems have been fixed in other issues.... closing this one out. Feel free to open again if the discussion turns back to a Media.

mpgeek’s picture

Issue summary: View changes

cc