Hi I am using userpoint 5.x-2.14 with drupal 5.1.

I have a very weird problem. For certain users, if they create a new node, then they get points. (30 point as I defined)

But if they modifies the content, then the original poster loses point and someone else gets 5 points. This 5 points is the point for adding comment.

* User xsaku earned 5 points! Total now is 570 points.
* User dragonkun lost 5 points! Total now is 1936 points.

Did anyone have the same problem?

I upgraded drupal 4.7 to 5.1 and 4.7 did not have this problem.

This problem started to happen after I upgraded to 5.x but I do not exactly remember which userpoints version started to trigger this problem.

CommentFileSizeAuthor
#10 userpoints_4.patch658 byteskmillecam

Comments

kmillecam’s picture

I'm experiencing a similar issue.

Upgraded to Drupal v5.1 over the weekend and now when I approve moderated comments, the poster loses his/her 5 points and I am awarded 5 points.

Kevin

kbahey’s picture

Category: support » bug
Priority: Normal » Critical

Setting this to critical.

mracarpenter’s picture

I have a wiki Drupal site and any time another user edits a wiki page that a different user created it will take the 30 points away from the creator and transfer it to the editor. I do not seem to have a problem with the comments though.

kmillecam’s picture

I was able to duplicate the behavior I was seeing (with comments) on a fresh install.

It appears to be related to the "preview" step in the approval/moderation process.

If I go to the list of comments pending approval and tick the checkbox next to them and approve the entire list, userpoints works as advertised.

But, if I open a comment on that list and approve it using the radio button under the "administer" heading, two entries are entered in the userpoints_txn table ... one that deducts the user's points and another that gives (what appears to be a random user) 5 points. Sometimes that user is me, sometimes it's another user, sometimes it's an anonymous user.

protoplasm’s picture

we are having problems with points being subtracted when someone edits a comment.

fhelmschrott’s picture

i second this and add the information that a random/changing user seems to get the points. today it is a user that doesn't even exist in the users database anymore (he got deleted).

Any help would be appreciated.

kmillecam’s picture

I changed the userpoints_comment() function in the userpoints.basic module to something that appears to have solved the problem.

It appears that the author was trying to reassign points in cases where the author of a comment was changed by the administrator. I probably have not interpreted the author's intent (please clarify if you have time) but I didn't see a case where a comment's author would be changed so I removed this code and things appear to be working as advertised.

I changed these lines (starting at approximiately line 110) ...
From this (before edits):

function userpoints_comment($comment, $op) {
  global $user;
  static $orig_uid;

  $points = variable_get(USERPOINTS_POST_COMMENT, 0);
  switch($op) {
    case 'insert':
      userpoints_userpointsapi('points', $points, $user->uid, 'post comment');
      break;
    case 'delete':
      $points = -$points;
      userpoints_userpointsapi('points', $points, $comment->uid, 'post comment');
      break;
    case 'moderate':
      $points = variable_get(USERPOINTS_MODERATE_COMMENT, 0);
      userpoints_userpointsapi('points', $points, $comment->uid, 'moderate comment');
      break;
    case 'form':
      $orig_uid = $comment['uid']['#value'];
    case 'update':
      if ($orig_uid != $comment['uid']['#value']) {
        // Add to the new comment owner
        userpoints_userpointsapi('points', $points, $comment['uid']['#value'], 'post comment');

        // Subtract from the original comment owner
        $points = -$points;
        userpoints_userpointsapi('points', $points, $orig_uid, 'post comment');
      }
      break;
  }
}

To this (after edits):

function userpoints_comment($comment, $op) {
  global $user;
  static $orig_uid;

  $points = variable_get(USERPOINTS_POST_COMMENT, 0);
  switch($op) {
    case 'insert':
      userpoints_userpointsapi('points', $points, $user->uid, 'post comment');
      break;
    case 'delete':
      $points = -$points;
      userpoints_userpointsapi('points', $points, $comment->uid, 'post comment');
      break;
    case 'moderate':
      $points = variable_get(USERPOINTS_MODERATE_COMMENT, 0);
      userpoints_userpointsapi('points', $points, $comment->uid, 'moderate comment');
      break;
    case 'form':
      $orig_uid = $comment['uid']['#value'];
    case 'update':
      break;
  }
}
yngens’s picture

I also have this problem. Could the module's maintainer confirm that it is ok to apply code change in #7, please. I do not want to break some other functionalities.

kbahey’s picture

Priority: Critical » Normal

kmillecam

Can you submit this as a patch to the latest 5.x?

kmillecam’s picture

Status: Active » Needs review
StatusFileSize
new658 bytes

Here's a patch against userpoints-5.x-2.14 that includes the changes listed above.

Kevin

kbahey’s picture

Title: modifying content substracts my point & add someone else' point » Modifying content substracts my point & add someone else' point
Status: Needs review » Postponed (maintainer needs more info)

I applied kmillecam's patch above.

However, this addresses only comments. Not sure if it will address other issues that are reported in this thread.

To everyone in this issue: please way for 12 hours from the time of this comment, then download the 5.x-dev tarball and see if it solves your problem. Report back what you find. If it solves them, then I will create a 5.x-2.15 official release.

ksoonson’s picture

it solved the original issue.

I am also curious other people's result.

yngens’s picture

i confirm suggested changes fixed the problem.

palik’s picture

i got 5.2 drupal with last stable userpoints and got this bug fixed by this patch

thank you! :)

jredding’s picture

Status: Postponed (maintainer needs more info) » Closed (fixed)

appears to be squashed.