Pathauto cleanstring errors on taxonomy term tokens

Created on 22 September 2012, over 12 years ago
Updated 3 February 2025, 3 months ago

When I use a custom token for taxonomy 'needs term' I get the following errors from pathauto:

Warning: Illegal offset type in isset or empty in pathauto_cleanstring() (line 180 of /var/www/wet/profiles/wetkit/modules/contrib/pathauto/pathauto.inc).
    Warning: html_entity_decode() expects parameter 1 to be string, array given in decode_entities() (line 429 of /var/www/wet/includes/unicode.inc).
    Warning: Illegal offset type in pathauto_cleanstring() (line 223 of /var/www/wet/profiles/wetkit/modules/contrib/pathauto/pathauto.inc).

I have been able to recreate this issue with a minimal set of modules and the following test case:

1. Define a custom token simply called "Testing" of type 'term' which prints the text 'testing'.
2. Create a test vocabulary with one term
3. In pathauto define a pattern for the vocabulary which is [term:testing]/[term:name]
4. Now edit your term and the error message should appear

To recreate the error messages programatically, you can run the following in devel/php:

$op = 'return';
module_load_include('inc', 'pathauto');
$term = taxonomy_term_load(1);
$uri['path'] = 'taxonomy/term/1';
$pathalias = pathauto_create_alias('taxonomy_term', $op, $uri['path'], array('taxonomy_term' => $term), $term->vocabulary_machine_name, 'en');

One thing I noticed is that hook_tokens in token_custom gets run twice, once with $options['recursive'] = TRUE and another time without. If I add the following to token_custom.module the error goes away and everything still seems to work:

175   if (isset($options['recursive'])) {
176     return $return;
177   }

I don't think this is the real fix, but I thought it may help debug the issue further.

🐛 Bug report
Status

Closed: outdated

Version

2.0

Component

Code

Created by

🇨🇦Canada joel_osc

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024