Related to #1700538: RelationQuery should not force the range of results to return

In troubleshooting why Search API was only loading 50 relations, I realized that the pseudo entity wrapper property for relations calls relation_rules_get_related_entities to load the related entities. This method has a hard limit of 50 as mentioned in above. @chx suggests in #1700538: RelationQuery should not force the range of results to return that the 50 limit be passed as a default rules option (I'm guessing he means rules parameter).

There are three reasons I'm confused here:

1) relation_rules_get_related_entities is NOT defined as a rules action in hook_rules_action_info. Do we need to write an action to call this and have limit as a parameter?
2) If no, relation_rules_get_related_entities is only used to define properties of the entity in relation_entity_property_info_alter(), so why is it in the rules file?
3) If the 50 limit is for preventing potential memory/timeout issues, is the alter below the best way around this situation

/**
 * Implements hook_entity_query_alter().
 */
function MYMODULE_entity_query_alter(&$query) {
  if (!empty($query->entityConditions['entity_type']) && !empty($query->entityConditions['bundle']) && !empty($query->range)) {
    $entity_info = entity_get_info('relation');
    $bundles = array_keys($entity_info['bundles']);
    if ($query->entityConditions['entity_type']['value'] == 'relation' && in_array($query->entityConditions['bundle']['value'], $bundles)) {
      unset($query->range);
    }
  }
}
CommentFileSizeAuthor
#3 remove-range-2259195-3.patch515 bytesmikran

Comments

andyg5000’s picture

Calling unset in my example above is bad and causes #2262331: EntityFieldQuery range() method not working when bundle is set for relation entities. The hard limit on 50 entities sucks and should be removed.

mikran’s picture

Assigned: Unassigned » mikran

Yes this relation_get_related_entities needs some updates. I'm not sure what to do with the limit though. Entity API adds related entities list to entity view and it does so using this getter callback. I'm debugging this issue that leads to htmlspecialchars() expects parameter 1 to be string, array given when getter callback returns an empty array. So I'm assigning this to myself for now...

mikran’s picture

Status: Active » Needs review
StatusFileSize
new515 bytes

I think it was just a mistake that this particular range(0,50) was not removed together with the removal of the other occurrences of this.

mikran’s picture

Status: Needs review » Fixed

  • mikran committed e7117b3 on 7.x-1.x
    Issue #2259195 by mikran, andyg5000: Rules integration, removed last...

Status: Fixed » Closed (fixed)

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