1

I'm trying to track down some performance issues on a Drupal 7 site where out of nowhere the site will stall rendering content or dealing with administrative duties like updating a piece of content. Checking the logs, I've found errors when cron runs for:

  • EntityMalformedException: Missing bundle property on entity of type node
  • Notice: Undefined property: stdClass::$nid in node_build_content()
  • Notice: Trying to get property of non-object in _node_index_node()

This prompted me to create a view to look at all content types and return

  • title,
  • node_id,
  • entity_id
  • entity_type

This view shows the majority of site content has entity_id = 0 and entity_type = null (nothing).

Out of roughly 400 nodes, less than 20 have proper entity_types and entity_id values. Even creating a simple basic page with a title and body results in entity_id = 0 and no value for the entity_type.

You would think that the content wouldn't render however, all of this content will render at /node/xxx or pulled up in views and can be edited as usual.

I think this is one of the causes of the poor performance if not the cause so I'm looking to repair the broken nodes and and prevent this site from continuing this odd behavior. I'm pretty sure the entity_id should equal node_id and I'm pretty sure the entity_type should equal node.

Drupal 7.34

1

This error can be caused by having a term reference field that references a deleted term. This reference is not deleted when a term is deleted.

You can check if this is the case using this query

SELECT nid, title from node WHERE nid 
   IN (select entity_id from  field_data_field_some_ref 
   WHERE field_some_ref_tid not IN (select tid from taxonomy_term_data))

https://www.drupal.org/node/1778572#comment-7256200

There are other cases where this error can occur. Read the issue comments in the link for more info.

  • Thanks Chris, I just ran the query. I only have a single term reference field called Categories so the query is as follows: SELECT nid, title from node WHERE nid IN (select entity_id from field_data_field_categories WHERE field_categories_tid not IN (select tid from taxonomy_term_data)) It returns zero rows. – Andrew Wasson Dec 2 '14 at 20:16
  • On second thought, I think your answer prompted part of the solution. When I looked at one of the content types I noticed there was an entity reference field for the Tags Taxonomy term. We weren't using it and a quick check showed none of the content was "tagged" so I removed that field from the content type and I no longer am receiving the first error: EntityMalformedException. I am still receiving the "Trying to get property of non-object" and the "Undefined property: stdClass::$nid". – Andrew Wasson Dec 2 '14 at 20:22
  • Try the accepted answer from here. It looks like possibly the same issue. – Chris M. Dec 2 '14 at 20:23
  • Hi Chris, Thanks for the direction. I had a look at that discussion and by a total fluke I found out it was the Site Info module that was causing the errors to be thrown. Now that it has been removed, the errors are gone but node content is still being produced without an entity_type and with entity_id = 0. I'm going to vote up your answer and search for discussions where entity_type is null and entity_id = 0. Thanks for all the help! – Andrew Wasson Dec 3 '14 at 1:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.