I am using D7 Beta1 and Token module 7.x-1.0-alpha 3. With the token module enable and no warning generated for other modules. Enabling the Login Toboggan module resulted in the following warning message:

Error message
Warning: uasort(): Array was modified by the user comparison function in token_get_info() (line 226 of /home/ww7ba/mobilesoftwaredev.com/sites/all/modules/token/token.module).

I had seen this error in a previous release of D7, but was unable to identify the module that was generating the message. The message now appears every time I enable a new module. If I disable Login Tobbogan the warming message goes away.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

hunmonk’s picture

Version: 7.x-1.0-alpha3 » 7.x-1.x-dev
Priority: Critical » Normal
Status: Active » Postponed (maintainer needs more info)

please try the latest development snapshots of all involved code and see if the issue still persists. also, can you reproduce this or a similar problem without enabling token module? if not, then the issue may also be with token module.

also, a warning is not a critical issue... ;)

billsdesk’s picture

I would gladly download and test the dev release, but it is not available from the module page. I was thinking about using CVS, but I don't have time for that approach.

I have already communicated with the Token maintainers, and they send me on the track to find the module that generated the warning messages. Of the many modules I have installed, Login Toboggan was the one that generated the error message. All other modules passed this test, but many failed in other tests.

Sorry about the over escalation. I have so many discrepancy reports filed for 7.x, that I some times overreact to get the attention of the developer.

hunmonk’s picture

I have already communicated with the Token maintainers, and they send me on the track to find the module that generated the warning messages.

could you please explain the process? the warning message clearly shows that the warning is being generated by code in the token module, so i'm not sure how you're arriving at logintoboggan as the culprit.

I would gladly download and test the dev release, but it is not available from the module page.

sure it is. click on 'View all releases', and scroll down to the 'logintoboggan 7.x-1.x-dev' release.

i'll wait for your report.

billsdesk’s picture

I downloaded and enabled the dev version, and still receive the warning message:

Warning: uasort(): Array was modified by the user comparison function in token_get_info() (line 226 of /home/ww7ba/mobilesoftwaredev.com/sites/all/modules/token/token.module).'

If I disable login toboggan the message goes away.

I like your module, which is why I am willing to test it.

Jarode’s picture

Hello,

I'm using Drupal 7.0-beta1 and logintoboggan-7.x-1.0-alpha3.
I have a similar error message when I enable loggingToboggan.

* Notice: Undefined index: name dans token_asort_tokens() (ligne 256 de /var/www/vhosts/kiki.fr.nf/httpdocs/drupal/sites/all/modules/token/token.module).
* Notice: Undefined index: name dans token_asort_tokens() (ligne 256 de /var/www/vhosts/kiki.fr.nf/httpdocs/drupal/sites/all/modules/token/token.module).
* Warning: uasort(): Array was modified by the user comparison function dans token_get_info() (ligne 226 de /var/www/vhosts/kiki.fr.nf/httpdocs/drupal/sites/all/modules/token/token.module).
* Notice: Undefined index: name dans _token_token_tree_format_row() (ligne 109 de /var/www/vhosts/kiki.fr.nf/httpdocs/drupal/sites/all/modules/token/token.pages.inc).
* Notice: Undefined index: description dans _token_token_tree_format_row() (ligne 112 de /var/www/vhosts/kiki.fr.nf/httpdocs/drupal/sites/all/modules/token/token.pages.inc).

Then, just after I reload modules page to see if the warning persist and I get that one:

* Notice: Undefined index: name dans _token_token_tree_format_row() (ligne 109 de /var/www/vhosts/kiki.fr.nf/httpdocs/drupal/sites/all/modules/token/token.pages.inc).
* Notice: Undefined index: description dans _token_token_tree_format_row() (ligne 112 de /var/www/vhosts/kiki.fr.nf/httpdocs/drupal/sites/all/modules/token/token.pages.inc).

Any idea ?
Need more infos ?

Thanks.

hunmonk’s picture

@billsdesk: you haven't answered this question...

could you please explain the process? the warning message clearly shows that the warning is being generated by code in the token module, so i'm not sure how you're arriving at logintoboggan as the culprit.

Dave Reid’s picture

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

The problem is that the token implementation in logintoboggan is just plain wrong.

1. The reported bug was caused because the module defined $info['types']['logintoboggan']['logintoboggan-validation'] = array() which is one level too many. Futhermore...
2. There's absolutely no need to define your own token type for just one token when this is obviously a user-related token. Modules had to do this with Drupal 6 because there were literally hundreds of tokens stuffed into node and user token types, but with token chaining in D7, that's no longer a problem. Patch moves the token to [user:validate-url] which just makes sense.
3. Removed unnecessary code copied from another token implementation.
4. Don't return any token value if you shouldn't be doing so. That's why we have $options['clean'] = TRUE in token_replace() rather than having modules return NULL values (it should be up to the module performing the token replacement decided what to do).
5. I've also moved the code to logintoboggan.tokens.inc as that's the standard for token-related functions in D7.

Dave Reid’s picture

Issue tags: +token

Tagging so I can keep track of all the modules I'm helping cleanup tokens for D7 with...

Jarode’s picture

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

Thanks for this patch, perfect. ++

Dave Reid’s picture

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

going to assume that was a cross-post. :)

hunmonk’s picture

Status: Needs review » Needs work

@Dave Reid: shouldn't case 'url': be case 'validate-url':?

Dave Reid’s picture

Status: Needs work » Needs review
FileSize
3.94 KB

Yep, good catch.

hunmonk’s picture

@Dave Reid: i'm a bit confused about putting the hooks in a separate file -- don't hooks normally go in the main .module file so they are accessible to other modules? also, how is this token.inc file loaded? does the core token code handle that?

@all: could somebody please test this latest patch to make sure it actually works as intended?

Dave Reid’s picture

Core automatically allows any of the token hooks to be put in a modulename.tokens.inc file because of the new hook_hook_info() in D7 (token hooks are declared in http://api.drupal.org/api/function/system_hook_info/7). Its why we can have modules/node/node.tokens.inc and modules/system/system.tokens.inc, etc in core.

Dave Reid’s picture

Using the user/%/devel pages available from Token module, my uid 1 user gets a [user:validate-url] token value of http://example.com/user/validate/1/1287202188/gsSHU39M3fQC-4vM-MAtF8_-KR...

Once I set the 'user registration' variable back to admin approval, I get an empty token as expected.

hunmonk’s picture

Status: Needs review » Fixed

@Dave Reid: thanks for all your help on this!

committed to HEAD.

Dave Reid’s picture

Woot, thanks to you too hunmonk!

HongPong’s picture

sub

Status: Fixed » Closed (fixed)
Issue tags: -token

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