I have three rules all meant to create/upadate/delete a taxonomy term using the node title as the term's value. The actual taxonomy term is NOT in the node form. I have the create one working, but both the update and delete rules fail with the following error:

Warning: array_values() [function.array-values]: The argument should be an array in rules_action_entity_query() (line 97 of /Users/kibots/Sites/drupal7/sites/all/modules/rules/modules/data.eval.in

Rules log shows:

0 ms Reacting on event After updating existing content.
8.167 ms Evaluating rule Update Project Taxonomy from Node Title (cloned).
8.872 ms The condition node_is_of_type evaluated to TRUE
8.892 ms AND evaluated to TRUE.
10.029 ms Evaluating the action entity_query.
14.532 ms Added the provided variable entity_fetched of type list
16.663 ms The variable or parameter entity_fetched is empty.
16.684 ms Unable to execute action drupal_message.
16.758 ms Finished reacting on event After updating existing con

I am guessing the log shows it fails because of the "The variable or parameter entity_fetch" empty bit. I cannot figure out if this an error triggered from my end, but after doing some test I suspect is an evaluation problem with the Fetch Entity.

The Fetch Entity by property is simple:

Entity Type: Taxonomy Term
Property: Name
Value (data selector): node:title

I have tried to do the same thing by setting a simple text variable, moving the node:title into it, then trying to use the resulting variable as the Value of the Fetch entity property afterwards with the same results. I also tried testing this by inputing the property value manually (the actual name of the term):

Entity Type: Taxonomy Term
Property: Name
Value (direct input): Example Project #1

And I still get the same results.

Bug or dev error?

CommentFileSizeAuthor
#4 entity_query.patch21.33 KBfago

Comments

dasjo’s picture

Component: Rules Core » Rules Engine

having the same problem here:

my rule with an entity query for a taxonomy_vocabulary by machine name

        { "entity_query" : {
            "USING" : {
              "type" : "taxonomy_vocabulary",
              "property" : "machine_name",
              "value" : "update_tags",
              "limit" : "1"
            },

leads to

Warning: array_values() [function.array-values]: The argument should be an array in rules_action_entity_query() (line 97 of .../modules/rules/modules/data.eval.in

debugging into the stated function

/**
 * Action: Query entities.
 */
function rules_action_entity_query($type, $property, $value, $limit) {
  $return = entity_property_query($type, $property, $value, $limit);
  return array('entity_fetched' => array_values($return));
}

yields

  dpm($type); .> taxonomy_vocabulary
  dpm($property); -> machine_name
  dpm($value); ->update_tags
  dpm($limit); -> 1
  dpm($return); -> NULL (empty)

so, it seems the entity_property query doesn't return the expected vocabulary and rules_action_entity_query can't deal with empty results

dasjo’s picture

Status: Active » Needs review

debugging into the function, reveals that entity_property_query fails, as it is missing the query callback method for the given property.

#1093918: Improve entity property query support fixes the problem for me

fago’s picture

Title: Fetch Entity by property problem » Fetch Entity by property won't work for all properties

Yep, apart from fixing that we need fix the Rules action to check which properties support querying. Probably best we should only add those properties in the options list.

fago’s picture

StatusFileSize
new21.33 KB
fago’s picture

uhm, sry the patch in #4 doesn't belong in this issue

Status: Needs review » Needs work

The last submitted patch, entity_query.patch, failed testing.

3rdLOF’s picture

So I did the patch in #2 an that did not fix it, as I presume fago implies in the follow up message. Should I preserve this patches and wait for a patch for this module or should I reverse it?

dasjo’s picture

kannary: the best way would be, if you could test fago's patch in #1093918: Improve entity property query support in order to mark it "reviewed and tested by the community"

3rdLOF’s picture

I did and it did not solve the problem.

3rdLOF’s picture

CORRECTION: Looks like it did fix the problem as far as the error reported above.

mrfelton’s picture

I'm having trouble fetching an entity by a property. I have two nodes, each with a number field, both values set to the same number. On saving one node, I'm trying to use rules to look up the other node by fetching it by the number property, and using the value from the first node as the selector value. The log shows that the entity was loaded, or at least, it says that it added a variable called drupal_project_maintainer_entity_fetched for it, but that variable doesn't seem to be available for use later on (I tried printing it as a message), neither does any entity seem to have actually been loaded.

Rule Drupal project user relations fires. [edit]
0 ms Rule Drupal project user relations fires.
1.394 ms Evaluating the action entity_query. [edit]
3.731 ms Added the provided variable drupal_project_maintainer_entity_fetched of type list<node> [edit]
5.019 ms Evaluating the action variable_add. [edit]
5.189 ms Added the provided variable relation_endpoints of type list<entity> [edit]
6.341 ms Evaluating the action list_add. [edit]
6.791 ms Evaluating the action list_add. [edit]
8.125 ms Evaluating the action entity_create. [edit]
13.278 ms Added the provided variable drupal_project_maintainer_relation of type relation [edit]
20.96 ms Evaluating the action drupal_message. [edit]
26.311 ms Evaluating the action drupal_message. [edit]
30.91 ms Evaluating the action drupal_message. [edit]
31.083 ms Rule Drupal project user relations has fired.
40.842 ms Saved drupal_project_maintainer_relation of type relation.
45.445 ms Finished reacting on event After updating existing content.

One of the earlier comments in this threads hints at it not being possible to query entities on all fields. Is fetching an entity by looking up the value stored in a number field supported?

vasike’s picture

i can cofirm this issue for a Product reference (Drupal Commerce) property.

rupertj’s picture

@vasike - I've had this issue on commerce product reference fields too, and I think I've found a fix. Issue here: https://drupal.org/node/1306106

vasike’s picture

for me it seems that are some conflicts with the Meta tags module. if i disable the metatags then it seems it works

dasjo’s picture

Component: Rules Engine » Rules Core
Status: Needs work » Fixed

i'm marking this as fixed. #1093918: Improve entity property query support has landed and i have created a follow up for handling bundle-specific properties #2058037: Support all entity properties in the entity query action.

Status: Fixed » Closed (fixed)

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