When showing a rather complex node, I find that feeds_entity_load() is called a lot of times. Below is a list of a node with 5 Terms and 1 countries-field.
The function adds the field feeds_nid to the entity. I am not sure what the function is of this field. I suppose it is only needed when importers are attached to the Node View page.

Anyway, there should be a smarter way to do this:
- either load/save this field together with the entity,
- or load only on affected pages, and only for the 'main' enitty.

Perhaps this issue is related: #1424992: Add implementation of hook_entity_info_alter() so that $node->feed_nid is available to Rules

SELECT entity_id, feed_nid FROM feeds_item WHERE entity_type = 'country' AND entity_id IN ('21')
SELECT entity_id, feed_nid FROM feeds_item WHERE entity_type = 'taxonomy_vocabulary' AND entity_id IN ('5')
SELECT entity_id, feed_nid FROM feeds_item WHERE entity_type = 'taxonomy_vocabulary' AND entity_id IN ('18')
SELECT entity_id, feed_nid FROM feeds_item WHERE entity_type = 'taxonomy_vocabulary' AND entity_id IN ('2')
SELECT entity_id, feed_nid FROM feeds_item WHERE entity_type = 'taxonomy_vocabulary' AND entity_id IN ('4')
SELECT entity_id, feed_nid FROM feeds_item WHERE entity_type = 'country' AND entity_id IN <all countries for options_list>
SELECT entity_id, feed_nid FROM feeds_item WHERE entity_type = 'taxonomy_vocabulary' AND entity_id IN ('11')
CommentFileSizeAuthor
#5 feeds-feeds_entity_load-1661014-5.patch2.46 KBtwistor
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

johnv’s picture

Addition to OP: The function is even called on pages like admin/structure/types/manage/MY_NODE_TYPE , where it definitely has no function.

stevector’s picture

feeds_entity_load() is an implementation of hook_entity_load so it does not control how often it is called or where it is called.

For this specific case, I'm guessing your content type has term fields, those term fields of course refer to terms of specific vocabularies. So on the config page for your node type it makes sense that any referenceable vocabularies would get loaded. And because vocabularies in D7 are themselves entities, hook_entity_load is going to get called.

johnv’s picture

@stevector , I understand why and when feeds_entity_load() is called.
However, for serving the purpose (load feeds_nid to do ...), perhaps another method could be better.

twistor’s picture

Assigned: Unassigned » twistor

I have been running into this as well, feeds_item gets huge very quickly. I don't actually know of any place in the code that accesses $entity->feed_nid generically. Maybe in the views code. We just need to make getting the feed_nid on-demand.

twistor’s picture

Status: Active » Needs work
FileSize
2.46 KB

Here's an initial patch. The token integration is the only change after removing hook_entity_load entirely. I haven't dug into the Views stuff, but that's pretty broken already.

johnv’s picture

@twistor, do you need anyone to test this patch?
As I've never used the feeds_nid actively, I would not find any errors.
(I find it problematic that Feeds cannot cope with nodes that are created manually/by another source, so I use Unique field as GUID, as per #661606: Support unique targets in mappers )

twistor’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

twistor’s picture

Assigned: twistor » Unassigned