This is related to #2853029: views_bulk_operations_action_load_list not working. Patch #8 (committed to the the dev version) fixed the issue with the action "Load a list of entity objects" but I'm finding the the list contains empty values when using the action "Load a list of entity IDs". [EDIT] Just to clarify, the list contains the correct number of items, but the values are empty.

Comments

argiepiano created an issue. See original summary.

argiepiano’s picture

Issue summary: View changes
argiepiano’s picture

Issue summary: View changes
argiepiano’s picture

Title: Rule action "Load a list of entity IDs from a VBO view" returns empty list » Rule action "Load a list of entity IDs from a VBO view" returns list with empty values
Issue summary: View changes
joelpittet’s picture

Status: Active » Postponed (maintainer needs more info)
Issue tags: +Needs steps to reproduce

This needs steps to reproduce the error, otherwise others can't help.

argiepiano’s picture

Steps to reproduce problem:

1. Create a bunch of nodes
2. Create a view of content to show those nodes. Be sure to include a "Bulk operations: Content" field
3. Create a rule component that contains the action "Load a list of entity ids from a VBO View." Select the view you created in 2.
4. In the rule, loop through the list and use each item to do something, for example, "Show a message on the site" and use the variable produced by the loop to show its value (e.g. The value of this item is: [list-item:value] )
5. Execute the component

You will get a bunch of messages (as many as there are items in the view), BUT instead of showing the ID of each, you get an empty value for each of the items.

argiepiano’s picture

StatusFileSize
new672 bytes

Patch attached. Works fine in my case. Please test.

argiepiano’s picture

Status: Postponed (maintainer needs more info) » Needs review
joelpittet’s picture

Thanks for the steps, I think this may be related to #1334374: Re-use generic entity views table from the code they both touch.

joelpittet’s picture

Status: Needs review » Needs work
Issue tags: -Needs steps to reproduce

Thank you for the patch, the code is supposed to produce an array of entity IDs. There is totally a bug if it's tossing entity objects in the list.

We could get the id of the entity, I'm going to test the steps

argiepiano’s picture

@joelpittet, something changed in Views version 3.15 that affected the VBO line:

$ids[] = $vbo->get_value($result);

Keep in mind that this line was present and was working fine in VBO version 7.x-3.3 when combined with Views 7-x.3.14.

The name of the variable I used in the patch $entity is misleading and wrong. The function $vbo->get_value($result) never "tossed entity objects". In fact this function always tossed entity IDs. The patch that I created basically falls back to this line if the user is still using Views 3.14. I should have used a different variable name.

nixar’s picture

The patch in #7 does seem to fix views_bulk_operations_action_load_id_list

However a similar problem exists for views_bulk_operations_action_load_list and this patch fixes the issue in this case.

I hope we can get a fix for the root of this since it was working fine a version ago.

maxplus’s picture

Thanks @nixar

I'm also using the current dev version (including patch from https://www.drupal.org/node/2853029#comment-11949835) together with patch #7 from this issue.
Now both my "Load a list of entity IDs from a VBO view" an "Load a list of entity objects from a VBO view" are working again

alison’s picture

YAAAAAAASSSSSSS omg that was an incredibly painful few hours, wrapped up nicely when I finally came across this issue :) I concur with @maxplus -- using the latest -dev along with the patch at #7 fixed my VBO-dependent rules. (I'd found #2853029: views_bulk_operations_action_load_list not working before, but it didn't help me, and I figured, dammit it's just me... But no!)

FWIW -- same here re: "the list contains the correct number of items, but the values are empty"

THANK YOU @argiepiano -- and @maxplus!

kcannick’s picture

@alisonjo2786 Does this only fix Loading list of IDs or loading list of entities as well?

argiepiano’s picture

@Kcannick the patch here only fixes the issue of ids being empty. To fix list of entity load see comments #12 and #13

nithinkolekar’s picture

what if base entity is of type User and need to get nid?

With some relationship added to content type like Article and field "Bulk operations: Content" with having relationship added, getting following error
Notice: Undefined property: stdClass::$nid in views_bulk_operations_action_load_id_list() (line 207 of /mysite/public/sites/all/modules/views_bulk_operations/views_bulk_operations.rules.inc).

if this expected behavior? (even with applied patch #7)

apmsooner’s picture

patch in #7 fixes my issue.

kcannick’s picture

Patch in #7 fixed my issue as well. When will this be committed?

sano’s picture

#7 works for me as well. Thanks

alansaviolobo’s picture

Status: Needs work » Reviewed & tested by the community

works for me

othermachines’s picture

I have a rule that iterates over a VBO view to send out emails to users and at some point this stopped working. I've traced the problem to this issue, and patch in #7 fixes it. Here's the rules debug info:

Before patch:

Rule Contributor creates content fires. 
  0 ms Rule Contributor creates content fires.
  0.018 ms Evaluating the action views_bulk_operations_action_load_id_list. 
  90.985 ms Added the provided variable domain_users_id_list of type list 
  92.46 ms Looping over the list items of domain-users-id-list 
  92.523 ms Evaluating the action entity_fetch. 
  103.766 ms Unable to load user with id ""
  105.152 ms Unable to evaluate action entity_fetch. 
  106.015 ms Evaluating the action mail.
  ...

 
After:

Rule Contributor creates content fires. 
  0 ms Rule Contributor creates content fires.
  0.027 ms Evaluating the action views_bulk_operations_action_load_id_list. 
  200.486 ms Added the provided variable domain_users_id_list of type list 
  224.561 ms Looping over the list items of domain-users-id-list 
  224.622 ms Evaluating the action entity_fetch. 
  239.999 ms Added the provided variable domain_user_entity of type user 
  241.699 ms Evaluating the action mail. 
  ...

 
Thanks!

chris matthews’s picture

codeyourdream’s picture

Status: Reviewed & tested by the community » Needs review
StatusFileSize
new673 bytes

The patch from #7 has the similar issue that is described in #2960424: Load a list of entity objects from a VBO View not working: loading IDs doesn't work when a field with identifier is not from a View's base table.
Attached is the updated patch.

izmeez’s picture

An interdiff might help illustrate the single line change in the patch. Here it is.

othermachines’s picture

Just noting that #7 still applies cleanly against latest dev. The new patch in #24 makes sense, but unfortunately I am unable to test it at the moment.