The origin of this discovery is due to the following error when search started indexing our content

EntityMalformedException: Missing bundle property on entity of type node. in entity_extract_ids() (line 7407 of /drupal/path/includes/common.inc).

Debugging it, I found that the node object is empty even though checking the node table and fields, the ID is present except in the node_revision table. We did a migration and probably in the middle of it there was an error that skipped the revision table. (It was only a 1 node that had a missing revision row).

Looking into it more, it's because of the SQL query in the entity.inc

SELECT revision.vid AS vid, base.uid AS uid, revision.title AS title, revision.log AS log, revision.status AS status, revision.comment AS comment, revision.promote AS promote, revision.sticky AS sticky, base.nid AS nid, base.type AS type, base.language AS language, base.created AS created, base.changed AS changed, base.tnid AS tnid, base.translate AS translate, revision.timestamp AS revision_timestamp, revision.uid AS revision_uid
FROM 
{node} base
INNER JOIN {node_revision} revision ON revision.vid = base.vid

Since it's using inner join, even if the ID is present in the node table, it will still return an empty result.

My question, is there any way we can avoid an empty node object? Or avoid an empty revision?

Comments

marcingy’s picture

Status: Active » Closed (won't fix)

Nodes should always have entries in the revisions table.

primerg’s picture

that's the problem though. for just only 1 node, it did not create that revision and it created a bunch of problem for us. and we are certainly using node_save to create a node during the migration so it's not like we are creating the table entries by hand.

but then this is only fyi. if you want to leave it as that, i dont mind this ticket to be ignored.