I'm getting random warning notices throughout the admin section of Drupal with the following errors.


    Warning: strnatcmp() expects parameter 2 to be string, array given in token_asort_tokens() (line 463 of /srv/clients/exampe/code/sites/all/modules/contrib/token/token.module). Backtrace:

    strnatcmp('Site information', Array) token.module:463
    token_asort_tokens(Array, Array) 
    uasort(Array, 'token_asort_tokens') token.module:429
    token_get_info() token.module:476
    token_get_global_token_types() token.module:508
    token_get_invalid_tokens_by_context(Array, Array) token.module:620
    token_element_validate(Array, Array) form.inc:1830
    form_builder('pathauto_patterns_form', Array, Array) form.inc:1822
    form_builder('pathauto_patterns_form', Array, Array) form.inc:1822
    form_builder('pathauto_patterns_form', Array, Array) form.inc:831
    drupal_process_form('pathauto_patterns_form', Array, Array) form.inc:366
    drupal_build_form('pathauto_patterns_form', Array) form.inc:123
    drupal_get_form('pathauto_patterns_form') 
    call_user_func_array('drupal_get_form', Array) menu.inc:517
    menu_execute_active_handler() index.php:21

    Warning: strnatcmp() expects parameter 2 to be string, array given in token_asort_tokens() (line 463 of /srv/clients/example/code/sites/all/modules/contrib/token/token.module). Backtrace:

    strnatcmp('Users', Array) token.module:463
    token_asort_tokens(Array, Array) 
    uasort(Array, 'token_asort_tokens') token.module:429
    token_get_info() token.module:476
    token_get_global_token_types() token.module:508
    token_get_invalid_tokens_by_context(Array, Array) token.module:620
    token_element_validate(Array, Array) form.inc:1830
    form_builder('pathauto_patterns_form', Array, Array) form.inc:1822
    form_builder('pathauto_patterns_form', Array, Array) form.inc:1822
    form_builder('pathauto_patterns_form', Array, Array) form.inc:831
    drupal_process_form('pathauto_patterns_form', Array, Array) form.inc:366
    drupal_build_form('pathauto_patterns_form', Array) form.inc:123
    drupal_get_form('pathauto_patterns_form') 
    call_user_func_array('drupal_get_form', Array) menu.inc:517
    menu_execute_active_handler() index.php:21

    Warning: strnatcmp() expects parameter 1 to be string, array given in token_asort_tokens() (line 463 of /srv/clients/example/code/sites/all/modules/contrib/token/token.module). Backtrace:

    strnatcmp(Array, 'Vocabularies') token.module:463
    token_asort_tokens(Array, Array) 
    uasort(Array, 'token_asort_tokens') token.module:429
    token_get_info() token.module:476
    token_get_global_token_types() token.module:508
    token_get_invalid_tokens_by_context(Array, Array) token.module:620
    token_element_validate(Array, Array) form.inc:1830
    form_builder('pathauto_patterns_form', Array, Array) form.inc:1822
    form_builder('pathauto_patterns_form', Array, Array) form.inc:1822
    form_builder('pathauto_patterns_form', Array, Array) form.inc:831
    drupal_process_form('pathauto_patterns_form', Array, Array) form.inc:366
    drupal_build_form('pathauto_patterns_form', Array) form.inc:123
    drupal_get_form('pathauto_patterns_form') 
    call_user_func_array('drupal_get_form', Array) menu.inc:517
    menu_execute_active_handler() index.php:21

    Warning: strnatcmp() expects parameter 2 to be string, array given in token_asort_tokens() (line 463 of /srv/clients/example/code/sites/all/modules/contrib/token/token.module). Backtrace:

    strnatcmp('View', Array) token.module:463
    token_asort_tokens(Array, Array) 
    uasort(Array, 'token_asort_tokens') token.module:429
    token_get_info() token.module:476
    token_get_global_token_types() token.module:508
    token_get_invalid_tokens_by_context(Array, Array) token.module:620
    token_element_validate(Array, Array) form.inc:1830
    form_builder('pathauto_patterns_form', Array, Array) form.inc:1822
    form_builder('pathauto_patterns_form', Array, Array) form.inc:1822
    form_builder('pathauto_patterns_form', Array, Array) form.inc:831
    drupal_process_form('pathauto_patterns_form', Array, Array) form.inc:366
    drupal_build_form('pathauto_patterns_form', Array) form.inc:123
    drupal_get_form('pathauto_patterns_form') 
    call_user_func_array('drupal_get_form', Array) menu.inc:517
    menu_execute_active_handler() index.php:21

    Warning: uasort(): Array was modified by the user comparison function in token_get_info() (line 429 of /srv/clients/example/code/sites/all/modules/contrib/token/token.module). Backtrace:

    uasort(Array, 'token_asort_tokens') token.module:429
    token_get_info() token.module:476
    token_get_global_token_types() token.module:508
    token_get_invalid_tokens_by_context(Array, Array) token.module:620
    token_element_validate(Array, Array) form.inc:1830
    form_builder('pathauto_patterns_form', Array, Array) form.inc:1822
    form_builder('pathauto_patterns_form', Array, Array) form.inc:1822
    form_builder('pathauto_patterns_form', Array, Array) form.inc:831
    drupal_process_form('pathauto_patterns_form', Array, Array) form.inc:366
    drupal_build_form('pathauto_patterns_form', Array) form.inc:123
    drupal_get_form('pathauto_patterns_form') 
    call_user_func_array('drupal_get_form', Array) menu.inc:517
    menu_execute_active_handler() index.php:21


I have been trying to trace the dependencies of what modules may be providing the wrote parameter type and why. What additional information would help with identifying a pattern to this error?

Comments

emptyvoid’s picture

Issue summary: View changes

removing client specific information.

Dave Reid’s picture

Category: bug » support
Status: Active » Fixed

Check your status report page (admin/reports/status). It means you some kind of conflict where two modules are trying to provide the same token.

emptyvoid’s picture

Hmm,

I will continue to investigate, the current breadcrumbs I can find are the pages where the warning errors appear the most often.

http://example.com/admin/config/search/path/patterns
http://example.com/admin/commerce/products/types/commerce-tshirt
http://example.com/admin/commerce/products/types/product/fields/field_image
http://example.com/admin/commerce/products/types/add

My first hunch is either Drupal Commerce or a sub-contrib module. I could also do a search through my contrib modules for hooks registering for tokens. However I got 989 matches.. so that isn't specific enough.

Is there a specific function or class in the token module I could debug (using xdebug) and step through to know when and where within the page execution stack this occurs?

I'd like to find the conflict then notify the correct module maintainers.

Thanks,

Dave Reid’s picture

The token module should be able to at least warn you on admin/reports/status which tokens are at fault and are causing the problem.

emptyvoid’s picture

Honestly I think is because I have a lot of modules enabled that provide hooks to add token keys on page load.. At some point it just gives up and pukes out errors.. It seems to be better now, perhaps it's tummy isn't upset any longer?

It still occurs but is less frequent, maybe is it acid reflux. I hear that's treatable. :P

If I happen to track down what module is causing the problem we can squash this whole lactose intolerant issue once and for all!

Dave Reid’s picture

You're giving me heartburn ignoring my instructions twice on how to help you figure out what is responsible for the errors.

Status: Fixed » Closed (fixed)

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

Kartagis’s picture

Status: Closed (fixed) » Active

Hi,

I've got the same issue, and /admin/reports/status doesn't tell me anything about conflicting tokens only gives the message Warning: strnatcmp() expects parameter 1 to be string, array given in token_asort_tokens() (line 569 of /var/www/clients/client4/web4/web/sites/all/modules/token/token.module). In my case, I have PHPmailer module installed. How can I debug it?

Regards,
K.

Kartagis’s picture

Issue summary: View changes

adding php tag for color coding.

kenorb’s picture

I had similar warning on cron run, after 2nd time it disappeared.

strnatcmp() expects parameter 2 to be string, array given token.module:569

Code:

function token_asort_tokens($token_a, $token_b) {
  return strnatcmp($token_a['name'], $token_b['name']);
}
deanflory’s picture

I just got these, now to figure out which modules are responsible:

The following token or token types are defined by multiple modules:
$info['tokens']['metatag']['fb:admins']
$info['tokens']['metatag']['fb:app_id']

Collins405’s picture

@deanflory How did you get that report?

deanflory’s picture

Run cron, see results in the Status Report like #9 when there is a Token conflict.

FYI, in my case, this turned out to be an issue with the Metatag module having some duplication going on in a dev release from a few weeks ago.

Updating to the latest "rc1" version of Metatag fixed my issue completely. Here's my issue in the Metatag queue: #2305433: Token types are defined by multiple modules: $info['tokens']['metatag']['fb:admins'] $info['tokens']['metatag']['fb:app_id']

Collins405’s picture

Thanks for getting back to me, however I guess Im not seeing the same problems, as this error was happening before I installed the Metatag module. Infact, even when disabling all contrib modules apart from token, the errors are still happening, and considering I haven't edited any core files, or hacked any token files, Im at a bit of a loss, because in a fresh install with just token, there are no problems.

Something is causing this though!

Notice: Undefined index: types in token_get_token_problems() (line 292 of /var/www/sites/all/modules/token/token.install).
Warning: Invalid argument supplied for foreach() in token_get_token_problems() (line 292 of /var/www/sites/all/modules/token/token.install).
Notice: Undefined index: tokens in token_get_token_problems() (line 307 of /var/www/sites/all/modules/token/token.install).
Warning: Invalid argument supplied for foreach() in token_get_token_problems() (line 307 of /var/www/sites/all/modules/token/token.install).

deanflory’s picture

A google search of your error(s) didn't bring up much more than this:
https://www.drupal.org/node/1888880

peterx’s picture

Latest software. I get the error when saving admin/people page:

Warning: strnatcmp() expects parameter 1 to be string, array given in token_asort_tokens() (line 569 of token/token.module).
Warning: strnatcmp() expects parameter 1 to be string, array given in token_asort_tokens() (line 569 of token/token.module).
Warning: strnatcmp() expects parameter 1 to be string, array given in token_asort_tokens() (line 569 of token/token.module).
Warning: strnatcmp() expects parameter 1 to be string, array given in token_asort_tokens() (line 569 of token/token.module).
Warning: strnatcmp() expects parameter 1 to be string, array given in token_asort_tokens() (line 569 of token/token.module).
Warning: uasort(): Array was modified by the user comparison function in token_get_info() (line 529 of token/token.module).

a: a:2:{s:4:"name";s:12:"Short format";s:11:"description";s:73:"A date in 'short' format. (2014-10-03 17:57)";}
b: a:2:{s:4:"name";s:13:"Raw timestamp";s:11:"description";s:73:"A date in UNIX timestamp format (1412323056)";}

a: a:2:{s:4:"name";s:13:"Raw timestamp";s:11:"description";s:73:"A date in UNIX timestamp format (1412323056)";}
b: a:2:{s:4:"name";s:10:"Time-since";s:11:"description";s:79:"A date in 'time-since' format. (44 years 9 months)";}

a: a:2:{s:4:"name";s:10:"Time-since";s:11:"description";s:79:"A date in 'time-since' format. (44 years 9 months)";}
b: a:2:{s:4:"name";s:12:"Short format";s:11:"description";s:73:"A date in 'short' format. (2014-10-03 17:57)";}

That short date string is in system_tokens.inc.