Userpoints 7.x-1.x allows modules which award points to declare their operations in hook_userpoints_info(). For these, operations is now a technical identifier and has most probably changed compared to 6.x versions.

This means that old transactions still show the untranslated operation/description.

This patch provides a simple framework that allows modules to convert existing transactions and update their operation/description to their updated ones.

It works quite simple:
- Userpoints selects all transactions which don't have a defined (through hook_userpoints_info()) operation and processes them with batch
- hook_userpoints_convert($transaction) is called for every of these transactions
- Any module that implements that hook can now "claim" such a transaction by setting the new operation and returning TRUE. If a module returns TRUE, the (updated) operation is persisted.

The advantage of this process compared to doing it during the upgrade is that it can be repeated whenever a module is enabled and it works in a fully bootstrapped with a clean state so we can use hooks and so on. Also, the modules implementing the hook only need a few lines of code, everything else is managed by userpoints.module.

Todo:
- I'm thinking about providing some statistics on that page: # unclaimed transactions and then splitted up by operation.

Patch for userpoints_nc.module follows soon. Without that, not much is going to happen :)

CommentFileSizeAuthor
userpoints_convert.patch5.11 KBberdir

Comments

berdir’s picture

Status: Active » Closed (duplicate)

duplicate

berdir’s picture

Status: Closed (duplicate) » Needs review

userpoints_convert.patch queued for re-testing.

berdir’s picture

Status: Needs review » Closed (duplicate)

Nah, wrong.