Action node is updated > set values on entity referenced user.
Action user is updated > set values on entity referenced node.
Obviously, this is going to cause recursion, since when I update the node, it updates the related user, which updates the node... and so on.
Elegantly, Rules detects the recursion and stops it.
However, somehow Rules doesn't allow for even the first iteration to fully occur. So, in my first rule I set multiple fields on the user, and then in my second rule I set multiple values on my referenced node. The trouble is that Rules is stopping the recursion before all the fields are set.
Is there a workflow I can devise that would permit these rules to complete the action of setting all the data values, but stop the next rule, that would begin the next recursive cycle, from being processed?
Any feedback is much appreciate. I have found quite a few StackOverflow and other posts that are relevant, but none that help me to work out a solution.
Thanks!
Comments
Comment #2
rogerrogers commentedThe solution is here: https://www.drupal.org/node/1704290#comment-8840959
This seems like a useful feature to have in Rules, and in fact works better than the recursion prevention functionality in place.
Without this, I was getting really odd results: the node being save wasn't persisting some of the changed field values. I assume it could be that the rules were firing out of sequence? thus the recursion occurred before the node save completed?
With this approach there is some predictability about how the recursion will be stopped.
Comment #3
oturpin commentedHello,
I'm using Rules 2.9 on Drupal 7.39.
I created a component which is targeted by a schedule : RecurSEPAPayment. This component creates a new payment entity.
I have a rule RecurringSEPAPayment which reacts on a payment entity creation, and set a schedule at current date +1 month on RecurSEPAPayment.
At once, RecurSEPAPayment is executed only once. Next execution is planned at +1 month.
I separated the rule and the component because user can create first payment by form.
My issue is that : RecurringSEPAPayment rule is blocked when payment is created by the scheduled component. It is not even executed once.
I looked for "recursion configuration" but only found this thread, which turns in fact on how to stop recursion...
I am probably not using Rules as I should do... But I don't see any solution yet.
Any idea ?
Here is the stack:
Dec 2 10:00:10 flurbiprofene EQUICOM: https://xxx/1449046810|rules|192.168.0.1|https://xxx/cron.php?cron_key=xxx||0||Rules debug information: " Scheduled evaluation of rule Recur SEPAPayment, task SEPAPayment-morannel-71-121.0 ms Scheduled evaluation of rule Recur SEPAPayment, task SEPAPayment-morannel-71-121.
0.161 ms Evaluating conditions of rule Recur SEPAPayment. [edit]
4.978 ms The condition entity_is_of_bundle evaluated to TRUE [edit]
5.057 ms AND evaluated to TRUE.
" Rule Recur SEPAPayment fires. [edit]0 ms Rule Recur SEPAPayment fires.
0.25 ms Evaluating the action php_eval. [edit]
" Reacting on event Après l'enregistrement d'une nouvelle entité commerce payment transaction.0 ms Reacting on event Après l'enregistrement d'une nouvelle entité commerce payment transaction.
0.325 ms Not evaluating reaction rule Recurring SEPA Payment to prevent recursion. [edit]
0.364 ms Evaluating conditions of rule UpdateSEPAPayment. [edit]
0.66 ms The condition entity_is_of_bundle evaluated to TRUE [edit]
0.681 ms AND evaluated to TRUE.
" Rule UpdateSEPAPayment fires. [edit]0 ms Rule UpdateSEPAPayment fires.
0.376 ms Evaluating the action data_set. [edit]
0.734 ms Evaluating the action data_set. [edit]
1.435 ms Evaluating the action data_set. [edit]
3.097 ms Rule UpdateSEPAPayment has fired.
3.845 ms Evaluating conditions of rule Commerce order message: payment entered. [edit]
3.86 ms AND evaluated to TRUE.
" Rule Commerce order message: payment entered fires. [edit]0 ms Rule Commerce order message: payment entered fires.
0.332 ms Evaluating the action entity_create. [edit]
1.504 ms Added the provided variable message of type message [edit]
1.869 ms Evaluating the action data_set. [edit]
2.209 ms Evaluating the action data_set. [edit]
2.448 ms Evaluating the action entity_save. [edit]
2.528 ms Saved message of type message.
77.295 ms Evaluating the action message_notify_process. [edit]
876.004 ms Rule Commerce order message: payment entered has fired.
880.158 ms Saved commerce_payment_transaction:user of type user.
" Reacting on event Après la mise à jour d'un compte utilisateur existant. [edit]0 ms Reacting on event Après la mise à jour d'un compte utilisateur existant.
0.374 ms Evaluating conditions of rule ClearIBANValidation. [edit]
0.79 ms The condition data_is evaluated to TRUE [edit]
1.002 ms The condition data_is evaluated to FALSE [edit]
1.015 ms AND evaluated to FALSE.
1.056 ms Evaluating conditions of rule CreateBillingProfileonUser. [edit]
1.068 ms AND evaluated to TRUE.
" Rule CreateBillingProfileonUser fires. [edit]0 ms Rule CreateBillingProfileonUser fires.
0.101 ms Evaluating the action php_eval. [edit]
55.273 ms Rule CreateBillingProfileonUser has fired.
56.412 ms Evaluating conditions of rule GenerateIBANValidation. [edit]
56.87 ms The condition data_is evaluated to FALSE [edit]
56.885 ms AND evaluated to FALSE.
56.905 ms Finished reacting on event Après la mise à jour d'un compte utilisateur existant.
1160.329 ms Saved commerce_payment_transaction of type commerce_payment_transaction.
" Reacting on event Après la mise à jour d'une entité commerce payment transaction existante. [edit]0 ms Reacting on event Après la mise à jour d'une entité commerce payment transaction existante.
0.3 ms Evaluating conditions of rule Update Recurring SEPA Payment. [edit]
0.586 ms The condition entity_is_of_bundle evaluated to TRUE [edit]
1.011 ms The condition data_is evaluated to FALSE [edit]
1.03 ms AND evaluated to FALSE.
1.065 ms Evaluating conditions of rule DecreaseCreditOnPayment. [edit]
1.248 ms The condition entity_is_of_bundle evaluated to FALSE [edit]
1.259 ms AND evaluated to FALSE.
1.289 ms Evaluating conditions of rule Commerce order message: payment confirmed. [edit]
1.59 ms The condition data_is evaluated to TRUE [edit]
1.764 ms The condition data_is evaluated to FALSE [edit]
1.775 ms AND evaluated to FALSE.
1.8 ms Finished reacting on event Après la mise à jour d'une entité commerce payment transaction existante.
1205.397 ms Finished reacting on event Après l'enregistrement d'une nouvelle entité commerce payment transaction.
1409.726 ms Rule Recur SEPAPayment has fired.
1414.928 ms Finished evaluation of rule Recur SEPAPayment, task SEPAPayment-morannel-71-121.
Comment #4
tr commented#1704290: Improve recursion prevent to cover saves of other rules as well