Download & Extend

Caching for the User's Points block

Project:User Points
Version:6.x-1.x-dev
Component:Code: userpoints_basic
Category:bug report
Priority:normal
Assigned:Unassigned
Status:needs work

Issue Summary

I recently decided to start using block caching on one of my sites and discovered an issue with the User's Points block. Basically, since it has no definition for the cache option, it defaults to BLOCK_CACHE_PER_ROLE as described at http://api.drupal.org/api/function/hook_block/6
The result is that all logged in users see the value that was last cached instead of their own points. To make this work, the block should be set to either BLOCK_CACHE_PER_USER or BLOCK_NO_CACHE.

Initially, I thought to just insert the cache bitmask as either per user or none, but then decided that it might be nicer to be able to set it via the edit interface for the block.

So, attached is a patch that adds that functionality. I included all the bitmask options although I don't know why anyone would want to use the others.

AttachmentSizeStatusTest resultOperations
userpoints.module.patch2.94 KBIgnored: Check issue status.NoneNone

Comments

#1

Category:feature request» bug report
Status:active» needs work

My suggestion would be to fix the bug by changing to BLOCK_NO_CACHE and include a hook_update_N() function to fix existing installs. Because for BLOCK_CACHE_PER_USER, we'd also have to think about clearing the cache when the points change...