When I enable the userpoints module (latest dev) I get 30+ instances of the following notices and warnings:
Notice: Undefined index: userpoints in _token_build_tree() (line 736 of /var/www/sites/all/modules/token/token.module).
Warning: Invalid argument supplied for foreach() in _token_build_tree() (line 736 of /var/www/sites/all/modules/token/token.module).

As well as a single instance of:
Notice: Undefined index: maxuserpoints in _token_build_tree() (line 736 of /var/www/sites/all/modules/token/token.module).
Warning: Invalid argument supplied for foreach() in _token_build_tree() (line 736 of /var/www/sites/all/modules/token/token.module).

I have the latest dev of token enabled. I suspect this is more a problem in token than userpoints, but thought I would check.

CommentFileSizeAuthor
#9 userpoints-tokens-1115984-9.patch1.35 KBdgynn

Comments

Sborsody’s picture

subscribe

shadowmihai’s picture

Component: Code: userpoints API » Code: userpoints

+1

BenK’s picture

Hmmm... let's see what Berdir thinks about this. I don't have this problem at all, but I'm also not quite up to date with the latest -dev of Token.

Can you downgrade Token to an earlier version and see if problems persist? I'm using a -dev version of Token from Jan 12, 2011, and don't have any problems.

--Ben

berdir’s picture

I can confirm that this issue exists, I'm seeing it too sometimes, although only 2-3 times and not 30+. I am also not sure yet when exactly it happens. Will investigate.

shadowmihai’s picture

I get it 30+ times - once for each user and it started with the last update of userpoints. I therefore think it is a userpoints issue, not a tokens issue, but the userpoints people closed it and said it was being dealt with here.

>> it would seem obvious that if it doesn't happen with userpoints beta 1 and does with beta 2 - and tokens didn't change in the meaintime, it is a userpoints issue and not a tokens issue. But then I'm not a coder...

Sborsody’s picture

I get these messages most of the time when viewing the module list page.

berdir’s picture

Status: Active » Postponed (maintainer needs more info)

Actually, I think I saw some other errors that are now gone after I updated some modules.

Are you sure that you are using the most recent version of both userpoints and token? The dev versions, I mean. token-7.x-1.0-beta1 is from january, which is rather old.

orendain’s picture

I had this same issue when updating to the latest userpoints release. Updating tokens to the latest dev version cleared it up.

Edit: Scratch that - errors still appear.

dgynn’s picture

StatusFileSize
new1.35 KB

I see this error when no userpoints categories have been defined. I've attached a patch that resolves the issue and seems to generate the right replacement values, even when no categories are used.

orendain’s picture

Thanks for the patch - seems to be working fine.

berdir’s picture

Status: Postponed (maintainer needs more info) » Needs review

Remember to set issues to needs review when you post patches.

Other than that, looks good, will verify and commit soon!

berdir’s picture

Status: Needs review » Fixed

Thanks, committed.

Adam S’s picture

What about the case when there isn't any Userpoints terms yet? The if (count($categories) > 1){ statement is not met and there will be no userpoint tokens and this error will occur. Can we have a default term to go with the default vocabulary?

berdir’s picture

That's exactly what this patch fixed by moving the all token out of that if condition so that there is always at least that.

Adam S’s picture

Yep, #9 works just great.

Status: Fixed » Closed (fixed)

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