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);
}
}
}
| Comment | File | Size | Author |
|---|---|---|---|
| #3 | remove-range-2259195-3.patch | 515 bytes | mikran |
Comments
Comment #1
andyg5000Calling 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.
Comment #2
mikran commentedYes this
relation_get_related_entitiesneeds 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 tohtmlspecialchars() expects parameter 1 to be string, array givenwhen getter callback returns an empty array. So I'm assigning this to myself for now...Comment #3
mikran commentedI 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.
Comment #4
mikran commented