Code for entity_extract_ids() in Common.inc throws error

Created on 29 May 2021, over 3 years ago
Updated 10 September 2023, about 1 year ago

Code for the function entity_extract_ids in common.inc is throwing error and rendering drupal 7.* useless. Error throwing needs to be replaced by warning or a watch dog entry.

In 7.80 the offending code is as follows: line 8025 to 8027

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

replacing line 8026 by the following solves the problem:

watchdog( "Drupal Error", "Missing bundle Property" ); return array();

It is hard to pin down the offending entities. It is easy to fix the error reporting mechanism. Error throwing doesn't belong in production code.

πŸ› Bug report
Status

Closed: works as designed

Version

7.0 ⚰️

Component
BaseΒ  β†’

Last updated 25 minutes ago

Created by

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡ΈπŸ‡ͺSweden arne_hortell

    Due to desperate need to migrate a D7 site which explodes due to this issue, i provide a patch which put error in log as above.

  • πŸ‡ΈπŸ‡ͺSweden arne_hortell

    It turns put common.inc have more issues, attaching patch for this.
    What happens in my case is that a schema does not have fields which makes it fail hard.
    This have been undetected for ages.

Production build 0.71.5 2024