I am using the userpoints, rules and token modules to add userpoints by a rules action to the current user's account at certain events and conditions. In the same rule I then try to display the new amount of userpoints for this user using a userpoints provided token [account:userpoints] in a display action.

At some cases where two rules are triggered by the same event, one after another, both adding userpoints and then displaying the new amount, the [account:userpoints] token appears to be outdated at the second rule's display action.

Originally I thought that the rules module would cause the problem and so added an issue at that module. But I learned that the problem seems to be originated by the token cache.

And as I also learned that disabling the token cache in rules would have a major influence on the performance, the better solution might be a rules action, provided by the token module, to "Clear the token cache", which could be added in such cases to the second rule.

Another option would be to create a new module, i.e. "rules clear token cache" to add this rules action.

Any reasons not to add such an action to the token module? Or do you suggest another solution?

Thanks for your support.
Christian.

Comments

Dave Reid’s picture

Status: Active » Postponed (maintainer needs more info)

If rules needs that action, then it seems like it would need to be provided by rules then? Token does not have anything rules-specific in it currently.

fago’s picture

Modules provide rules integration on their own - Rules doesn't provide any actions for contribs. Thus it should go into the token module (or a separate module). Also token has already Rules integration, which provides token replacements to Rules as input evaluator.

I think that action might be useful in quite some cases, lots of users suffer from bugs stemming from the token cache. I repeatedly get issues for that in auto-nodetitle, but clearing the cache every time would just make things slower. The action would enable users suffering from the problem to clear the cache manually when necessary.

fago’s picture

It would also fit into the http://drupal.org/project/cache_actions module though.

meichr’s picture

Fago, thanks for your finding and pointing out. I second this idea and have posted a feature request issue at that module.

I also was thinking that a module solely for this "Clear Token Cache" action might be too much and cluttered, if it can be avoided.

Christian.