EntityMalformedException: Missing bundle property on entity of type taxonomy_term

Date: 
Thursday, July 12, 2018 - 17:15

When attempting to run any form of operation involving batching the operation either fails and throws error or perform the task and throw error:
EntityMalformedException: Missing bundle property on entity of type taxonomy_term. in entity_extract_ids() (line 7933 of /var/www/html/main.marketplace/includes/common.inc).

Project: 
Status: 
completed
Priority: 
high
Applied Status: 
Website: 
shopperita.com
Stage: 
Production

Comments

Posted by developer7 on 07/12/2018 - 17:18

The following function from common.inc above seems to be what is throwing the error
function entity_extract_ids($entity_type, $entity) {
$info = entity_get_info($entity_type);

// Objects being created might not have id/vid yet.
$id = isset($entity->{$info['entity keys']['id']}) ? $entity->{$info['entity keys']['id']} : NULL;
$vid = ($info['entity keys']['revision'] && isset($entity->{$info['entity keys']['revision']})) ? $entity->{$info['entity keys']['revision']} : NULL;

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)));
}
$bundle = $entity->{$info['entity keys']['bundle']};
}
else {
// The entity type provides no bundle key: assume a single bundle, named
// after the entity type.
$bundle = $entity_type;
}

return array($id, $vid, $bundle);
}

Posted by developer7 on 07/12/2018 - 18:31

The issue could have something to do with programmatically saving taxonomy terms using taxonomy_term_save(). The issue being not having a valid vid property set on the term object (https://www.drupal.org/project/drupal/issues/1270340#comment-6810552)

Posted by developer7 on 09/05/2018 - 13:10

Running Cron before the batch operation (Search Api Solr) causes some of the operation to be completed before the error is thrown

Posted by developer7 on 09/06/2018 - 11:54

Adroid's Solution to a similar issue on Drupal.org
// I used PHP formatting just to color the 'feed_item' part in my post...you should run this query in phpMyAdmin or similar.
SELECT
n.nid,
n.title,
n.vid,
nr.vid
FROM
node n
LEFT JOIN
node_revision nr
ON nr.nid = n.nid
WHERE
n.type = 'feed_item'
AND nr.vid IS NULL
ORDER BY
n.nid ASC

https://www.drupal.org/project/drupal/issues/1778572#comment-6891428

Posted by developer7 on 09/07/2018 - 11:47

The Problem seems to be related to the Data alteration processing order (DATA ALTERATIONS under the Filters tab)

Data alteration processing order
This order caused error
Index hierarchy
URL field

This order DOES NOT cause error
URL field
Index hierarchy

Project Management