Caching for the User's Points block

fred0 - November 5, 2009 - 06:47
Project:User Points
Version:6.x-1.x-dev
Component:Code: userpoints_basic
Category:feature request
Priority:normal
Assigned:Unassigned
Status:active
Description

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.

AttachmentSize
userpoints.module.patch2.94 KB
 
 

Drupal is a registered trademark of Dries Buytaert.