Today I edited a page and got many errors as follow:
notice: Array to string conversion in .../drupal/sites/all/modules/token/token.module on line 280.
I printed some debug to see what happens, there are 4 entries that are saved in the $full->values array as array instead of strings.
// from $tokens
[92]=>
string(10) "[menupath]"
[93]=>
string(14) "[menupath-raw]"
[158]=>
string(10) "[termpath]"
[159]=>
string(14) "[termpath-raw]"
// from $full->values
[92]=>
array(1) {
[0]=>
string(25) "Ubuntu Versions and Names"
}
[93]=>
array(1) {
[0]=>
string(25) "Ubuntu Versions and Names"
}
[158]=>
array(1) {
[0]=>
string(8) "Articles"
}
[159]=>
array(1) {
[0]=>
string(8) "Articles"
}
The two are created in this way because of pathauto.
In pathauto.module, we have those for the termpath[-raw] variables:
$values[$label . 'path'] = !empty($options['pathauto']) ? $catpath : implode('/', $catpath);
$values[$label . 'path-raw'] = !empty($options['pathauto']) ? $catpath_raw : implode('/', $catpath_raw);
And in token.module, we've got those two for the menupath[-raw]:
$values['menupath'] = !empty($options['pathauto']) ? $trail : implode('/', $trail);
$values['menupath-raw'] = !empty($options['pathauto']) ? $trail_raw : implode('/', $trail_raw);
Was pathauto expected to do something about these in token_prepare_tokens()?
That would not be possible since the $full->values is not passed down, but I was wondering if that's what was expected before and it would have changed? At this time, it looks like we should remove these special tests and just use the string generated by the right hand side.
Thank you.
Alexis Wilke
| Comment | File | Size | Author |
|---|---|---|---|
| #4 | 1174472-token-improve-generate-cache-fail.patch | 1.21 KB | dave reid |
| #3 | 1174472-token-improve-generate-cache.patch | 5.34 KB | dave reid |
Comments
Comment #1
dave reidThat is what the pathauto_clean_token_values() function does, yes. But I think I see what's happening. We're not caching tokens based on $options! GAH.
Comment #2
dave reidComment #3
dave reidComment #4
dave reidAnd testing that the added test should actually *fail*.
Comment #6
dave reidCommitted #3 to Git: http://drupalcode.org/project/token.git/commit/10d0912