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 :)

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Berdir’s picture

Status: Active » Needs review
Berdir’s picture

When testing this patch, I heavily suggest to create a backup of the userpoints_txn table both to being able to restore if something goes wrong and being able to reproduce the converting.

Berdir’s picture

When testing this patch, I heavily suggest to create a backup of the userpoints_txn table both to being able to restore if something goes wrong and being able to reproduce the converting.

Status: Needs review » Needs work

The last submitted patch, userpoints_convert.patch, failed testing.

Berdir’s picture

Status: Needs work » Needs review
BenK’s picture

Subscribing to help with testing.

BenK’s picture

Bumping this so that I don't lose track.

Berdir’s picture

FileSize
4.6 KB

I successfully confused the testbot with my duplicate issues.

Here is a new patch, needed a re-roll anyway.

BenK’s picture

Status: Needs review » Needs work

Hey Berdir,

I tested the latest patch and it worked well. I had old style UP-NC operations and they were successfully converted to the new format. Double-checked with phpmyadmin and everything seemed great. Here are some potential usability suggestions:

1. Do we want this as it's own tab? If so, I'd put it to left of the settings tab. But maybe it could be a vertical tab since most people aren't likely to use this a lot. Another option could be to make this its own sub-module so that only people who need it enable it. I'm just not sure if warrants a whole horizontal tab to itself.

2. Any way to provide an "undo" link to undo the most recent operation? Because this actually changes the database (even though it is a pretty harmless change), we might want a way to revert this if it has unforeseen affects (if someone clicks the "convert transactions" button by mistake). This would be especially needed if some other Userpoints-related module (one that we don't work on) incorrectly implemented the operation change. On alternate approach would be to just provide a confirmation dialog box upon clicking the button so that we're sure it was intentional.

3. Yes, a few basic statistics (like you suggested) would be great. It's nice to know whether your system needs to be updated and what will happen if you click the "convert transactions" button.

4. Probably needs a sentence or two of explanation at the top of the page. If you suggest something, I can refine it.

--Ben

Berdir’s picture

Title: Provide framework to allow modules to update their transaction » Provide framework to allow modules to update their transaction (D7)
Project: User Points » User Points Contributed modules
Version: 7.x-1.x-dev » 6.x-1.x-dev
Component: Code: userpoints API » Code

Thought about this and I think, this doesn't belong into the mail. Moving to userpoints contrib.

BenK’s picture

Version: 6.x-1.x-dev » 7.x-1.x-dev