This happens when updating record for points using userpoints_userpointsapi.

Lets take for example user uid=5 and:
1) create points record, set 100 points
2) update this record using userpoints_userpointsapi, set 50 points instead of 100.

result:
in table userpoints_txn there is one record for uid=5 with 50 points
in table userpoints there is one record for uid=5 with 150 points
problem : 50!=150

Mistake in file userpoints.module in method _userpoints_update_cache.

instead of :

  // Calculate the current points based upon the tid
  $current_points = (int)$params['points'] + userpoints_get_current_points($params['uid'], $params['tid']);
  //Grab the user's maximum points to preserve it
  $max_points = db_result(db_query('SELECT max_points FROM {userpoints} WHERE uid = %d AND tid = %d',
    $params['uid'], $params['tid']));
  if ($params['points'] > 0) {
    //points are greater than zero, update their max_points
    $max_points = (int)$params['points'] + (int)$max_points;
  }

should be something like

  $row = db_fetch_object(db_query('select sum(points) s, max(points) m from {userpoints_txn} where uid=%d and tid=%d',$params['uid'], $params['tid']));
  $current_points=$row->s;
  $max_points=$row->m;

Comments

berdir’s picture

Status: Active » Postponed (maintainer needs more info)

There are many bugfixes in the 6.x-1.x-dev release, please try if it is working correctly there or not.

berdir’s picture

Version: 6.x-1.1 » 6.x-1.x-dev
Status: Postponed (maintainer needs more info) » Active

Yes, editing transactions is currently not working at all once they have been approved.

We're working on that in the 7.x version, will have to check if a backport is possible.

manuel.adan’s picture

Component: Code: userpoints_basic » Code: userpoints
Issue summary: View changes
Status: Active » Closed (outdated)

Closing this as outdated, 6.x version is no longer maintained.