The pages on my site are shown without the theming, it is a collection of links and data.

I also get this error:

EntityMalformedException: Missing bundle property on entity of type file. in entity_extract_ids() (line 8097 of /home/customer/www/theorichel.nl/public_html/includes/common.inc).

This has been reported before: https://www.drupal.org/project/file_entity/issues/2421609 but since that one was obsolete I was recommended to post again.

I am on D 7.98
PHP 7.4.33
File Entity 2.37
Media 2.30

Many thanks

Comments

TheoRichel created an issue. See original summary.

theorichel’s picture

Thank you very much!

I have applied this patch: https://www.drupal.org/project/drupal/issues/2931500 as per your suggestion

and it gave me back my site which is great), though the error message 'EntityMalformedException..) remains on top of my pages.

When I flush my cache I get:

Warning: session_set_save_handler(): Cannot change save handler when headers already sent in drupal_session_initialize() (line 245 of /home/customer/www/theorichel.nl/public_html/includes/session.inc).
Warning: session_start(): Cannot start session when headers already sent in drupal_session_start() (line 304 of /home/customer/www/theorichel.nl/public_html/includes/session.inc).
Warning: Cannot modify header information - headers already sent by (output started at /home/customer/www/theorichel.nl/public_html/includes/common.inc:1) in drupal_send_headers() (line 1555 of /home/customer/www/theorichel.nl/public_html/includes/bootstrap.inc).
Warning: Cannot modify header information - headers already sent by (output started at /home/customer/www/theorichel.nl/public_html/includes/common.inc:1) in drupal_send_headers() (line 1555 of /home/customer/www/theorichel.nl/public_html/includes/bootstrap.inc).
Warning: Cannot modify header information - headers already sent by (output started at /home/customer/www/theorichel.nl/public_html/includes/common.inc:1) in drupal_send_headers() (line 1555 of /home/customer/www/theorichel.nl/public_html/includes/bootstrap.inc).

..... and more of the same.

For the warning Drupal suggests patching the statistics module, but that has alread been done.

joseph.olstad’s picture

I saw this issue myself this weekend, it came up when I tried to load an entity that was already loaded, I had to back off some of my custom code that was re-loading the entity, I ended up figuring out that the entity was already there and I didn't need to load it again in my custom code.

Check your custom code and recent changes that may have brought this issue up?

theorichel’s picture

Im not smart enough for custom code, but I did remove some modules though I do not know which ones anymore. Can I still see that history in my database?

joseph.olstad’s picture

if you run update.php or drush updb your site should warn you about modules that were removed from the filesystem but not uninstalled.

theorichel’s picture

I get access denied when I try to run update.php . The rest of the site (be it with the Malformed error and without theming) is accessible.

joseph.olstad’s picture

@TheoRichel,
You'll need to be logged in with an administrator role to access update.php

Please try again.

If you forgot your password but you have a terminal access you can use the login token generated using drush uli;

theorichel’s picture

Sorry but I am logged in. I can install and uninstall modules, always accompanied by the mentioned errors, but it works. Update.php though says access denied.

joseph.olstad’s picture

It's possible that someone intentionally removed Update.php from your build.

You may want to make sure you're logged in as user id 1 (administrator)
the drush uli command gives a token that will log you in as user id 1 provided you're logged out before using the token.

jon nunan’s picture

After some debugging I found:
https://api.drupal.org/api/drupal/includes%21entity.inc/function/DrupalD...
You'll see when building the query it grabs a list of fields from:
$entity_fields = $this->entityInfo['schema_fields_sql']['base table'];

For whatever reason, the values in 'schema_fields_sql' do not include the bundle field. So when the file entity is loaded via that controller it will be missing its bundle and trip up entity_extract_ids().

I think the issue is hook_schema_alter(); should that be in .install or should it be in .module?
When debugging and clearing cache, I don't hit a breakpoint I place inside `file_entity_schema_alter()` in its current location in the `.install` file. I think that hook only gets picked up if its in the module file? I tried moving the hook to the .module file, and while I now hit the breakpoint I cache clear the issue still remains.

I found I could fix the issue by just hardcoding the bundle field in the entity_info_alter() but this feels like a hack and there is something else I'm missing

function file_entity_entity_info_alter(&$entity_info) {
  $entity_info['file']['fieldable'] = TRUE;
  $entity_info['file']['entity keys']['bundle'] = 'type';
  $entity_info['file']['bundle keys']['bundle'] = 'type';
  $entity_info['file']['schema_fields_sql']['base table'][] = 'type';
joseph.olstad’s picture

Hmm, ya, strange , try upgrading to 7.x-2.38 and Drupal core to 7.99

sounds like this is fixable, with that said, this is something I've seen in the past, sounds like it's something that can be fixed outside of file_entity, but with that said, feel free to elaborate a patch if that helps.

anybody’s picture

I'm running into this after updating to 7.x-2.38 (from 7.x-2.37) and Drupal 7.99. Still unclear, why it happens in my case...

anybody’s picture

Any ideas how we can get more information about the root cause?
May this be a single malformed (file) entity? I see some file entities without type in my file list (fonts and csv's).

For now I'm using the hack from #12 successfully.

joseph.olstad’s picture

@Anybody,
you could disable the hack and debug entity_extract_ids() in core includes/common.inc

Try to find out which ones are crashing, work backwards.

So you're saying you have file entities without type in your file list? fonts and csvs? Maybe you can simply add a type and update your file_managed records that have no type?

or the file entity records, have to see where that's stored.