HI,

I wanted to add the action "Fetch entity by property". There is a field for the limit. The default value is 10. So i cleared the field in hope to switch off the limitation. Fail! Only 10 results. I inserted 0. Fail! 0 results. By inserting -1 an SQL-Error occurs on the result.

Maybe it would be helpful to insert a checkbox. So the user can decide if he wants to use the limit function or not.

Greets
Cebra

Comments

Cebra’s picture

Issue summary: View changes

Removed spelling errors

tr’s picture

Issue summary: View changes
Status: Active » Closed (won't fix)

I don't see how we can do that within Rules, not without a lot of work. This is because we use the Entity API to make the query. The function entity_property_query() takes $limit as an argument, and $limit defaults to 30. entity_property_query() then passes that $limit on to entity_metadata_table_query() as a mandatory argument - no default value provided. Then with entity_metadata_table_query() the query range() is set to range(0, $limit). There will ALWAYS be a range set because of this. The only way to force the range to be not set is for the first argument to range() be NULL, but since it's hardwired to 0 in the Entity API a range will always be used and $limit has to be a non-negative number.

So there's no way to just not pass the $limit, even if we had a checkbox, and there's no way to prevent the query from having a range. That's a failure of the Entity API and needs to be fixed there. This Rules condition is behaving exactly as designed, and the Entity API doesn't let us change that short of copying the Entity API code into Rules and modifying it. That's too extreme at this late stage of the D7 development cycle. As a workaround you can set $limit to a very large number.

Note that this DOES work in Drupal 8 - leaving $limit blank in D8 results in all entities being returned.