I've tried several values for the URL, including path aliases, node/some_nid, and absolute paths. All result in the same error, shown below. The rest of the rule's actions fail because there is no result to act upon. If I fetch by nid, it works, however in this use case I do not know the nid, but I can construct the pattern for the path alias.
Warning: array_values() expects parameter 1 to be array, null given in rules_action_entity_query() (line 56 of /vol/www/humweb/sites/all/modules/rules/modules/entity.eval.inc).
Comments
Comment #1
jeff.k commentedI am experiencing the same issue when trying to load a user from their user url
Comment #2
realEuph commentedThis is the last key component in finishing off a project. I am researching the problem and reporting results here. I am trying to load a entity (node) by URL. I have used the full path (including http:) and the relative path. This is not yet a solution, but a report on what I have found.
I added print_r statements (using drupal_set_message) to dump out the structure of $return (defined in rules/modules/entity-eval.inc\\line 55) and $info (displayed just prior to entity/includes/entity.property.inc\\line 135).
rules_action_entity_query is what is called to process the fetch by URL property
rules_action_entity_query calls entity_property_query with same arguments
The dump of $return is empty/null (don't check)
The dump of $info is:
If $info['query callback'] is not empty, then $info['query callback']($entity_type, $property, $value, $limit) is returned. As can be seen above, $info['query callback'] is empty.
I am still investigating why no query is in $info.
Comment #3
realEuph commentedSorry - restored old title
Comment #4
realEuph commentedAfter several hours working through 'entity_property_query' in entity/includes/entity.property.inc and 'rules_action_entity_query' in rules/modules/entity.eval.inc', I still don't know what is happening. I fell that this is more due to my lack of detailed knowledge of these modules than anything else.
For URL requests the structure returned by 'entity_get_all_property_info' does not contain information in the 'url' key that allows the function to return the desired information. In particular $info['queryable'] and $info['quert callback'] are not set. There is a comment about supporting the "deprecated query callback" that may not be supported from 'entity_get_all_property_info' because $info['getter callback'] is defined ('entity_metadata_entity_get_properties').
If I force setting $info['queryable'] and $info['quert callback'] (to 1 and 'entity_metadata_entity_get_properties', respectively), then the code fails when calling the callback because $property is not an array. If I make it one, the callback returns nothing.
When using the action "Fetch Entity by Author", significantly different results are present in the $properties object, leading to the return of the requested number of nids.
I suspect that there are two problems here:
Comment #5
tigin öztürk commentedBy using conditional rules, the property of entity can be fetch without using action "Fetch entity by property".
Add a conditional in the action part of rules. Than "If: Entity has field" is a good choice of fetching entity...
Comment #6
nicolas bouteille commentedI can't seem to do it either.
I submit an entityform embeded in a node. I need to retrieve the node where the form has been submitted. I have printed site:current-page:path and site:current-page:url they are both referring to the correct node. But when I do entity fetch by property choosing Node and URL and select site:current-page:url, I get the exact same error message.
Comment #7
robdubparker commentedI ran into the same issue... I was trying to fetch an entity by url property, and got the same errors. As a workaround I added a custom module to handle the path to nid conversion, then used "fetch entity by id" option instead. This did the trick. Code I used in the custom module is below. Hope this helps.
Comment #8
Yuri commentedThis should be included in Rules. There are many use cases such as forms and entities in panels that need the current entity ID.