1

Rues and VBO are not working as expected to delete nodes. Can someone tell me what I'm missing? Thank you.

What I have:

  1. A View with VBO field which successfully selects all nodes of a certain type based on how long ago they were created. (The Preview shows all the desired nodes.)

  2. A Rules Action set which: Rules Action Set

A. Load a list of entity objects from a VBO View. Obviously the chosen View is the View from step 1 above.

B. Loop through the list of entity objects.

C. Deletes each list item using "Delete entity".

  1. A Rule which runs on cron and has for its only action the above Action Set (and no conditions).

However, it's not working. I run cron via drush and none of the nodes are deleted.

I have cleared all caches, recreated each part of the process from scratch (i.e. not cloning anything)... but it's still not working.

I have also created a Page display in the View (because the Rules Action set uses the Master display) and I can successfully manually delete the nodes with VBO - it's just not working when used in a Rule/Action Set.

However, the site is already deleting User entities with an identical Views/VBO/Rules/Cron setup.

Has anyone come across this or have any idea what might be wrong? Thanks.

  • Have you defined a trigger for the rule to fire on cron? – Anson W Han Nov 22 '17 at 1:02
  • @AnsonWHan Yes ;) – penname Nov 22 '17 at 12:15
2

Here is an "educated" guess:

  1. Your site is configured so that anonymous users are NOT allowed (= do not have the permission) to delete nodes.
  2. Cron (always) runs with user anonymous.

Up to you to confirm if bullet "1." applies, but rest assured that bullet "2." is true (in any Drupal 7 site). So if "1." indeed applies, the answer to your question (= "What am I missing") is that to get this to work you need to grant delete of nodes to anonymous users. I bet it is not going to be what you want to do (I wouldn't ...), but trust me, that is what you're missing.

And BTW, it must be that the userid you used to "successfully manually delete the nodes with VBO" does have the required permission.

To verify if my guess makes sense: (temporary) grant access to the VBO view to anonymous users, logout from your site, and repeat your manual attempt to delete the nodes with that VBO view again (as anonymous user). I bet it will fail with some sort of permission issue. Turn on Rules debugging (within Rules sessings) to get more details about that via the Rules logging messages shown near the top of your screen).

  • Pierre.Vriens Thank you! I came to the same realization :) The problem is the permissions settings on the content type. Anonymous users are not allowed to delete. But granting privileges to anonymous users is not a good solution in this case. Is there another solution? – penname Nov 22 '17 at 12:15
  • new question created here: drupal.stackexchange.com/q/250774/55739 – penname Nov 22 '17 at 12:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.