userpoints_expire.module uses an array containing the key 'event' to call userpoints_userpointsapi(), which is documented to accept an array with the key 'operation'.

CommentFileSizeAuthor
#8 event-to-operation.patch5.33 KBkbahey

Comments

kbahey’s picture

Project: User Points Contributed modules » User Points
Component: Code: userpoints_expire » Code: userpoints API

Actually, the README.txt for the API still documents the name of the parameter as 'event', although the database column is called 'operation'.

So the module is doing the right thing.

However, for consistency, we may want to rename the parameter event to operation in a future API overhaul.

Thus moving to Userpoints API project.

kbahey’s picture

Title: userpoints_expire.module uses a wrong parameter for userpoints_userpointsapi() » Rename 'event' parameter in userpoints_userpointsapi() to 'operation'

Changing the title to be more descriptive.

avpaderno’s picture

That is not exact. It's userpoints_expire.module which uses the wrong parameter.

avpaderno’s picture

Project: User Points » User Points Contributed modules
Component: Code: userpoints API » Code: userpoints_expire
Status: Active » Needs review

The problem is not with userpoints_userpointsapi(), but with the modules which use it.
They use $params['event'] when they should use $params['operation'].

avpaderno’s picture

Status: Needs review » Active
kbahey’s picture

Project: User Points Contributed modules » User Points
Component: Code: userpoints_expire » Code: userpoints API

Kiam

Did you read the README.txt document before changing the issue back?

Go and read here under "API".

It says:

'event' => (string) varchar32 descriptive identifier administrative purposes

So, the parameter name is still event, not operation. This is why it needs to change in Userpoints API, before the other modules can be changed.

avpaderno’s picture

I think we are talking of two different things.
If the README.txt is not updated, that is one issue; the issue I am talking of is that the modules don't use the correct parameter (or the parameter with the correct name, if you prefer).

If the README.txt isn't updated, the inline documentation is updated, or I would not have known which parameters userpoints_usperpointsapi() requires.

kbahey’s picture

Status: Active » Needs review
StatusFileSize
new5.33 KB

I think we are both right, and both wrong too.

userpoints_userpointapi() has this:

/**
 * @param $params(array) or (int)
 *    if (int) assumed to be points for current user
 *    Accepts an array of keyed variables and parameters
 *    'points' => # of points (int) (required)
 *    'moderate' => TRUE/FALSE
 *    'uid' => $user->uid
 *    'operation' => 'published' 'moderated' etc.

And the code has 'operation' everywhere.

However, there is just one place that still has 'event', here:

  // Call the _userpoints hook, and stop if one of them returns FALSE
  $rc = module_invoke_all('userpoints', 'points before', $params['points'], $account->uid, $params['event']);

I am attaching a patch for 5.x-3.x that would make it all "operation" instead of the old "event".

If you and jredding can review this patch and see if it does not break anything, then I will commit it, then I will do a wholesale change for the userpoints_contrib as well, with one issue (since the change is the same for all modules).

We also need to port this patch to 6.x later.

kbahey’s picture

The parallel issue for userpoints_contrib is here http://drupal.org/node/265764

Review of both patches needed.

avpaderno’s picture

Status: Needs review » Reviewed & tested by the community
kbahey’s picture

@jredding

Can you eye over this one please?

jredding’s picture

The hook should've also been called operation and not event and an eyeball over the patch looks OK.

The change doesn't affect any existing code so I suggest we put it straight into 5.3.6 and roll a new release.

kbahey’s picture

Version: 5.x-3.x-dev » 5.x-3.6
Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.