3

I'm seeing a strange behavior on my site and I'm trying to figure out how to correct it.

I have a rule that triggers on the event After updating an existing user account. This rule uses two variables, account and account-unchanged. Both of these should be provided by default.

However, for some reason user accounts are being saved upon login-- and when they are saved at login, account-unchanged is unset. This leaves a PHP warning in watchdog.

To remove this error, I attempted to add a condition, Not data value is empty (account-unchanged, but this just gives me another watchdog warning like so:

Unable to evaluate condition data_is_empty.

Ideally I will be able to find the reason why user accounts are being saved on login, but in the meantime, is there a way to prevent the rule from being evaluated when a required variable is not set?

  • Have you tried turning on Show debug information in the Settings in Rules? It will give you a breakdown of everything that is happening when the rule is fired and should help you solve the problem. – Tasha Nov 20 '14 at 17:02
  • I have the debug information turned on; it gives me the exact same information as watchdog. – Patrick Kenny Nov 20 '14 at 17:06
2

Have a look at issue # 430274, about an event which is a variation of your event here, and somehow explains that "after saving something" actually happens "before saving something". This is not a bug, but simply how the Rules module works.

A possible compromise to avoid these kind of issues, is to transform what's you're trying to do into a Rules component, so that your original Rule "schedules the execution" (using the Rules Scheduler sub-module) of that Rules component. For example after only a few seconds or minutes if your cron job runs frequent enough (otherwise it'll be next time cron runs). This compromise will ensure that, at the time the Rules component is executed, the entity is for sure saved (so that can't be the reason anymore then why things don't work as expected).

Note: maybe it's worth to do some Rules debugging, as detailed in "How can I display the value of a variable inside a condition?"

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.