Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
After clear cache, a warning is coming :
Warning: Illegal string offset 'name' in token_asort_tokens() (line 577 of project/modules/contrib/token/token.module).
Patch (need to be reviewed):
line 577
/**
* uasort() callback to sort tokens by the 'name' property.
*/
function token_asort_tokens($token_a, $token_b) {
if(is_array($token_a) && is_array($token_b) ) {
if(array_key_exists('name',$token_a) && array_key_exists('name',$token_b)) {
return strnatcmp($token_a['name'], $token_b['name']);
}
}
}
Comment | File | Size | Author |
---|---|---|---|
#2 | illegal_string_offset_name-2709053-1.patch | 559 bytes | gemalm |
|
Comments
Comment #2
gemalmHi,
I tested the code and the warning is gone so I created the patch. I got the same warning in 7.x-1.6 and 7.x-1.7
Comment #3
Dave ReidComment #4
Dave ReidI would say this is an issue with whatever tokens are not setting the 'name' array key, I'm not sure this is something we should hide when something else is going wrong.