I've encountered a problem (Drupal 6 website) using tokens with rules (and userpoints) which is caused by tokens being cached between different rules triggered by the same event. In two or more rules for the same event I add userpoints (rules action) to a user and also display the resulting total (using [account:userpoints] token) in each rule. The problem is that the first userpoints total is displayed correctly, but in the second or later rule triggered from the same event the total is displayed incorrectly with the same amount as in the first one.
The rules module maintainer, Fago, traced this back to the tokens being cached and suggested in this bug report and this token feature request issue to implement a rules action to clear the Token cache for such cases by an appropriate module, and pointed at this module as a good candidate.
So, what about integrating a "Clear Token Cache" action to this module?
Thanks for consideration,
Christian.
Comments
Comment #1
fabsor commentedHi!
The token module adds it's own cache table and defines it in hook_flush_caches. That means that this should already be possible by using the clear cache bins action that this module provides.
Try this:
* Create a new rule and select the action "Clear cache bins"
* Select cache token and save.
This should remove the token cache for you.
Comment #2
meichr commentedHi,
thanks a lot for the explanation, I'll try it out during the next days.
One thought I've right now is whether clearing more then just the token cache might have much impact on the duration of the page load. I'll have to test this on a test site before I can tell whether this would use significantly more time compared with not clearing the cache bins or clearing the token cache only by PHP code. I'll post here about my findings after the tests.
Christian.
Comment #3
fabsor commentedHi!
When using the clear cache bins action, you can select which cache bins you want to clear. That means you can select only the token cache bin, and leave the rest of the caches untouched.
Comment #4
fabsor commentedI'm closing this issue, since it is now very old and it should be possible to do with cache actions.
Comment #5
mtndan commentedHi, I'm reopening this because token cache doesn't appear to be an option when selecting cache bins in rules.
I see:
cache
cache_block
cache_filter
cache_page
cache_path
cache_apachesolr
cache_content
cache_tax_image
cache_views
cache_views_data
cache_rules
Comment #6
dave reidTokens are statically cached. They need to be cleared by calling
token_get_values('reset');