When regenerating content aliases I am now seeing the following warnings, one per alias.

warning: mb_strtolower() expects parameter 1 to be string, array given in /var/www/drupal/includes/unicode.inc on line 435.

CommentFileSizeAuthor
#15 token_time.module.txt3.69 KBskizzo

Comments

dave reid’s picture

1. Make sure you're using Token 6.x-1.15 or newer.
2. Double check your admin/reports/status page for a 'Duplicate token' warning. If you see one, please report it back here.

greggles’s picture

Status: Active » Postponed (maintainer needs more info)
skizzo’s picture

I am running 6.x-1.15 (2010-10-07). When I rebuild the node paths the PHP errors are logged in dblog (the aliases are correctly created). There is no mention of token in /admin/reports/status.

greggles’s picture

What other modules are you using that have token implementations?

skizzo’s picture

List of the currently available tokens on this site

CCK date
CCK file
CCK link
CCK node reference
CCK number
CCK text
Comment
Date
Domain
File
Flag
Flag-action
Global
Link
Node
Node reference
Number
String
Taxonomy
Text
User
User reference

skizzo’s picture

Not sure if following info is of any interest... anyway:
if I expand all available tokens, sort, count duplicates,
and list associated module, this is what I get

2 d (Date, Node)
2 date
2 day
2 dd
2 ddd
2 formatted (Number,Text)
2 link (User Reference, Node Reference)
2 m (Date, Node)
2 mm
2 mon
2 month
2 nid (Node Reference, Node)
2 path (Node Reference,User reference)
3 raw (Node, Number, Text)
3 title (Link, Node, Node Reference)
2 title-raw (Node Reference, Node)
2 uid (User, User Reference)
3 url (User Reference,Node Reference, Link)
2 view (Date,Link)
2 vocab (Node,Taxonomy)
2 vocab-raw
2 ww (Date,Node)
2 yy
2 yyyy

greggles’s picture

They have to be duplicates at the same level.

You are likely going to need to do something like this:

in pathauto.inc change:

  $tokens = token_prepare_tokens($full->tokens);
  $values = pathauto_clean_token_values($full, $options);

to be:

  $tokens = token_prepare_tokens($full->tokens);
  watchdog('debug', var_export($tokens, true));
  $values = pathauto_clean_token_values($full, $options);

Then look in the watchdog for an array at a level where everything else is strings.

skizzo’s picture

As I have no programming skills I can't really tell. What I get is the following debug record. Does that alone tell you something?

array ( 0 => '[domain-id]', 1 => '[domain-name]', 2 => '[domain-name-raw]', 3 => '[domain-url]', 4 => '[domain-url-raw]', 5 => '[domain-subdomain]', 6 => '[domain-subdomain-raw]', 7 => '[domain-default-id]', 8 => '[domain-default-name]', 9 => '[domain-default-name-raw]', 10 => '[domain-default-url]', 11 => '[domain-default-url-raw]', 12 => '[user-name]', 13 => '[user-id]', 14 => '[user-mail]', 15 => '[site-url]', 16 => '[site-name]', 17 => '[site-slogan]', 18 => '[site-mission]', 19 => '[site-mail]', 20 => '[site-date-yyyy]', 21 => '[site-date-yy]', 22 => '[site-date-month]', 23 => '[site-date-mon]', 24 => '[site-date-mm]', 25 => '[site-date-m]', 26 => '[site-date-ww]', 27 => '[site-date-day]', 28 => '[site-date-ddd]', 29 => '[site-date-dd]', 30 => '[site-date-d]', 31 => '[site-date-small]', 32 => '[site-date-raw]', 33 => '[site-date-since]', 34 => '[site-date-date]', 35 => '[site-date]', 36 => '[current-page-title]', 37 => '[current-page-path]', 38 => '[current-page-path-raw]', 39 => '[current-page-url]', 40 => '[current-page-number]', 41 => '[page-number]', 42 => '[save-lineage-termpath-raw]', 43 => '[save-lineage-termpath]', 44 => '[save-lineage-termpath:4]', 45 => '[save-lineage-termpath-raw:4]', 46 => '[save-lineage-termpath:5]', 47 => '[save-lineage-termpath-raw:5]', 48 => '[save-lineage-termpath:7]', 49 => '[save-lineage-termpath-raw:7]', 50 => '[save-lineage-termpath:79]', 51 => '[save-lineage-termpath-raw:79]', 52 => '[save-lineage-termpath:80]', 53 => '[save-lineage-termpath-raw:80]', 54 => '[save-lineage-termpath:86]', 55 => '[save-lineage-termpath-raw:86]', 56 => '[save-lineage-termpath:89]', 57 => '[save-lineage-termpath-raw:89]', 58 => '[save-lineage-termpath:94]', 59 => '[save-lineage-termpath-raw:94]', 60 => '[save-lineage-termpath:96]', 61 => '[save-lineage-termpath-raw:96]', 62 => '[save-lineage-termpath:97]', 63 => '[save-lineage-termpath-raw:97]', 64 => '[save-lineage-termpath:98]', 65 => '[save-lineage-termpath-raw:98]', 66 => '[save-lineage-termpath:100]', 67 => '[save-lineage-termpath-raw:100]', 68 => '[save-lineage-termpath:101]', 69 => '[save-lineage-termpath-raw:101]', 70 => '[save-lineage-termpath:103]', 71 => '[save-lineage-termpath-raw:103]', 72 => '[save-lineage-termpath:105]', 73 => '[save-lineage-termpath-raw:105]', 74 => '[save-lineage-termpath:106]', 75 => '[save-lineage-termpath-raw:106]', 76 => '[save-lineage-termpath:108]', 77 => '[save-lineage-termpath-raw:108]', 78 => '[save-lineage-termpath:109]', 79 => '[save-lineage-termpath-raw:109]', 80 => '[save-lineage-termpath:110]', 81 => '[save-lineage-termpath-raw:110]', 82 => '[save-lineage-termpath:113]', 83 => '[save-lineage-termpath-raw:113]', 84 => '[save-lineage-termpath:115]', 85 => '[save-lineage-termpath-raw:115]', 86 => '[nid]', 87 => '[type]', 88 => '[type-name]', 89 => '[language]', 90 => '[title]', 91 => '[title-raw]', 92 => '[node-path-raw]', 93 => '[node-path]', 94 => '[node-url]', 95 => '[author-uid]', 96 => '[author-name]', 97 => '[author-name-raw]', 98 => '[author-mail]', 99 => '[author-mail-raw]', 100 => '[log-raw]', 101 => '[log]', 102 => '[node_comment_count]', 103 => '[unread_comment_count]', 104 => '[yyyy]', 105 => '[yy]', 106 => '[month]', 107 => '[mon]', 108 => '[mm]', 109 => '[m]', 110 => '[ww]', 111 => '[day]', 112 => '[ddd]', 113 => '[dd]', 114 => '[d]', 115 => '[small]', 116 => '[raw]', 117 => '[since]', 118 => '[date]', 119 => '[mod-yyyy]', 120 => '[mod-yy]', 121 => '[mod-month]', 122 => '[mod-mon]', 123 => '[mod-mm]', 124 => '[mod-m]', 125 => '[mod-ww]', 126 => '[mod-day]', 127 => '[mod-ddd]', 128 => '[mod-dd]', 129 => '[mod-d]', 130 => '[mod-small]', 131 => '[mod-raw]', 132 => '[mod-since]', 133 => '[mod-date]', 134 => '[menu]', 135 => '[menu-raw]', 136 => '[menupath]', 137 => '[menupath-raw]', 138 => '[menu-link-title]', 139 => '[menu-link-title-raw]', 140 => '[menu-link-mlid]', 141 => '[menu-link-plid]', 142 => '[term]', 143 => '[term-raw]', 144 => '[term-id]', 145 => '[vocab]', 146 => '[vocab-raw]', 147 => '[vocab-id]', 148 => '[activity-node-link]', 149 => '[activity-node-creator-link]', 150 => '[flag-bookmarks-count]', 151 => '[flag-automoderazione-count]', 152 => '[medium]', 153 => '[large]', 154 => '[g]', 155 => '[G]', 156 => '[h]', 157 => '[H]', 158 => '[i]', 159 => '[s]', 160 => '[U]', 161 => '[mod-medium]', 162 => '[mod-large]', 163 => '[mod-g]', 164 => '[mod-G]', 165 => '[mod-h]', 166 => '[mod-H]', 167 => '[mod-i]', 168 => '[mod-s]', 169 => '[mod-U]', 170 => '[termpath]', 171 => '[termpath-raw]', 172 => '[termalias]', 173 => '[termalias-raw]', )

greggles’s picture

Nothing in there looks like a problem to me. I'm stumped.

dave reid’s picture

We need to debug the token values, not the token names. Change the line from:
watchdog('debug', var_export($tokens, true));
to
watchdog('debug', var_export($full->values, true));

greggles’s picture

(my bad)

skizzo’s picture

Here you go. I just replaced real FQDN and mail with fake data (mydomain.com being the "primary" Domain Access domain). Maybe the problem lies with dates (115 => and 130 =>) ???


array ( 0 => '0', 1 => 'mydomain', 2 => 'MYDOMAIN', 3 => 'mydomaincom', 4 => 'mydomain.com', 5
=> 'www', 6 => 'www', 7 => 0, 8 => 'mydomain', 9 => 'MYDOMAIN', 10 => 'mydomaincom', 11 =>
'mydomain.com', 12 => 'admin', 13 => '1', 14 => 'admin@mydomain.com', 15 =>
'http://mydomain.com/en', 16 => 'MYDOMAIN', 17 => 'site slogan...', 18 => 'site
mission...', 19 => 'noreply@mydomain.com', 20 => '2010', 21 => '10', 22 => 'October',
23 => 'Oct', 24 => '10', 25 => '10', 26 => '41', 27 => 'Thursday', 28 => 'Thu',
29 => '14', 30 => '14', 31 => '14 Oct 2010 - 22:58', 32 => 1287089887, 33 => '0
sec', 34 => '4', 35 => '14 Oct 2010 - 22:58', 36 => 'URL aliases', 37 =>
'admin/build/path/pathauto', 38 => 'admin/build/path/pathauto', 39 =>
'http://mydomain.com/en/admin/build/path/pathauto', 40 => 1, 41 => 1, 42 => false,
43 => false, 44 => '', 45 => '', 46 => '', 47 => '', 48 => '', 49 => '', 50 =>
'', 51 => '', 52 => '', 53 => '', 54 => '', 55 => '', 56 => '', 57 => '', 58 =>
'', 59 => '', 60 => '', 61 => '', 62 => '', 63 => '', 64 => '', 65 => '', 66 =>
'', 67 => '', 68 => '', 69 => '', 70 => '', 71 => '', 72 => '', 73 => '', 74 =>
'', 75 => '', 76 => '', 77 => '', 78 => '', 79 => '', 80 => '', 81 => '', 82 =>
'', 83 => '', 84 => '', 85 => '', 86 => '20821', 87 => 'topic', 88 => 'TOPIC',
89 => 'it', 90 => 'Placerat aliquet urna', 91 => 'Placerat aliquet urna', 92 =>
'node/20821', 93 => 'node/20821', 94 => 'http://mydomain.com/en/node/20821', 95 =>
'27', 96 => 'guestuser', 97 => 'guestuser', 98 => 'xxx@mydomain.com', 99 =>
'xxx@mydomain.com', 100 => '', 101 => '', 102 => '0', 103 => '0', 104 =>
'2010', 105 => '10', 106 => 'September', 107 => 'Sep', 108 => '09', 109 => '9',
110 => '38', 111 => 'Sunday', 112 => 'Sun', 113 => '26', 114 => '26', 115 =>
array ( 0 => '26 Sep 2010 - 17:38', 1 => '26 Sep 2010 - 17:38', ), 116 =>
'1285515521', 117 => '2 weeks 4 days', 118 => '7', 119 => '2010', 120 => '10',
121 => 'September', 122 => 'Sep', 123 => '09', 124 => '9', 125 => '38', 126 =>
'Sunday', 127 => 'Sun', 128 => '26', 129 => '26', 130 => array ( 0 => '26 Sep
2010 - 17:38', 1 => '26 Sep 2010 - 17:38', ), 131 => '1285515521', 132 => '2
weeks 4 days', 133 => '7', 134 => '', 135 => '', 136 => '', 137 => '', 138 =>
'', 139 => '', 140 => '', 141 => '', 142 => 'Section Two', 143 => 'Section Two',
144 => '18082', 145 => 'Section', 146 => 'Section', 147 => '86', 148 =>
'Placerat aliquet urna', 149 => 'guestuser', 150 => 0, 151 => 0, 152 => 'Sun,
26/09/2010 - 17:38', 153 => 'Sunday, 26 September, 2010 - 17:38', 154 => '5',
155 => '17', 156 => '05', 157 => '17', 158 => '38', 159 => '41', 160 =>
'1285515521', 161 => 'Sun, 26/09/2010 - 17:38', 162 => 'Sunday, 26 September,
2010 - 17:38', 163 => '5', 164 => '17', 165 => '05', 166 => '17', 167 => '38',
168 => '41', 169 => '1285515521', 170 => array ( 0 => 'Section Two', ), 171 =>
array ( 0 => 'Section Two', ), 172 => 'section/section-two', 173 =>
'section/section-two', )

dave reid’s picture

So it looks like the [small] token is getting defined twice. The [termpath] and [termpath-raw] tokens should be arrays by design and not actually be causing problems.

dave reid’s picture

Status: Postponed (maintainer needs more info) » Fixed

You'll have to make sure you're using the latest Token module and then go to admin/reports/status to find out which modules are at fault for defining the [small] token more than once.

skizzo’s picture

StatusFileSize
new3.69 KB

Nothing reported by /status, but going through all my modules I noticed the attached "token_time" : Add missing tokens for hours, minutes, seconds. You can disable this module once a new version of token is out. (but then you have to change all your tokens to the format supported in the new version of token!). A forgotten patch maybe... After removing it the annoying warning seems gone. Thank you.

heyyo’s picture

warning: mb_eregi_replace() expects parameter 3 to be string, array given in /home/heyyoyo/sites/sites/rimonim-israel.com/modules/pathauto/pathauto.inc on line 136.
warning: mb_strtolower() expects parameter 1 to be string, array given in /home/heyyoyo/sites/includes/unicode.inc on line 441.
warning: mb_eregi_replace() expects parameter 3 to be string, array given in /home/heyyoyo/sites/sites/rimonim-israel.com/modules/pathauto/pathauto.inc on line 136.
warning: mb_strtolower() expects parameter 1 to be string, array given in /home/heyyoyo/sites/includes/unicode.inc on line 441.

I get this error every time I edit page of a content type which uses taxonomy. No error is returned if I edit page which doesn't use taxonomy.

I modified the pathauto.inc to get the debug, but not sure waht to look for:

array ( 
0 => 'Aventure en Israel, Trek Neguev, Jeep, Rappel, Chameau, Rafting, Plongée, Equitation', 
1 => 'Aventure en Israel, Trek Neguev, Jeep, Rappel, Chameau, Rafting, Plongée, Equitation', 
2 => 'http://yoyo.com/user', 
3 => '', 
4 => 'Rimonim Israel', 
5 => 'http://yoyo.com', 
6 => 'Rimonim Israel', 
7 => 'Rimonim Israel', 
8 => 'info@yoyo.com', 
9 => '+972 (0)54 8359340', 
10 => '', 
11 => 'Rimonim Israel Jerusalem JE ', 
12 => 'http://yoyo.com/', 
13 => 'admin', 
14 => '1', 
15 => 'yoyo@gmail.com', 
16 => 'http://yoyo.com/', 
17 => 'Rimonim Tours', 
18 => 'Discover Israel Differently with Tour Guides', 
19 => '', 
20 => 'info@yoyo.com', 
21 => '2010', 
22 => '10', 
23 => 'December', 
24 => 'Dec', 
25 => '12', 
26 => '12', 
27 => '48', 
28 => 'Saturday', 
29 => 'Sat', 
30 => '04', 
31 => '4', 
32 => '12/04/2010 - 10:32', 
33 => 1291458765, 
34 => '0 sec', 
35 => '6', 
36 => 'Aventure', 
37 => 'node/34/edit', 
38 => 'node/34/edit', 
39 => 'http://yoyo.com/node/34/edit', 
40 => 1, 
41 => '12/04/2010 - 10:32', 
42 => 1, 
43 => '1218', 
44 => '', 
45 => 'jeep and co 088.jpg', 
46 => 'sites/yoyo.com/files/tyul/jeep and co 088.jpg', 
47 => 'image/jpeg', 
48 => '125443', 
49 => '122.5 KB', 
50 => 'jeep and co 088.jpg', 
51 => 'jeep and co 088', 
52 => 'jpg', 
53 => '412', 
54 => 'Trek dans le désert', 
55 => 'Trek dans le désert', 
56 => 'Trek dans le désert', 
57 => '/node/412', 
58 => 'http://yoyo.com/node/412', 
59 => '34', 
60 => 'tyultype', 
61 => 'Tyul type', 
62 => 'fr', 
63 => 'Aventure', 
64 => 'Aventure', 
65 => 'node/34', 
66 => 'node/34', 
67 => 'http://yoyo.com/node/34', 
68 => '3', 
69 => 'webmaster', 
70 => 'webmaster', 
71 => 'info@yoyo.com', 
72 => 'info@yoyo.com', 
73 => '', 
74 => '', 
75 => '4', 
76 => '0', 
77 => '2009', 
78 => '09', 
79 => 'April', 
80 => 'Apr', 
81 => '04', 
82 => '4', 
83 => '14', 
84 => 'Wednesday', 
85 => 'Wed', 
86 => '01', 
87 => '1', 
88 => '04/01/2009 - 09:18', 
89 => '1238577534', 
90 => '1 year 35 weeks', 
91 => '3', 
92 => '2010', 
93 => '10', 
94 => 'December', 
95 => 'Dec', 
96 => '12', 
97 => '12', 
98 => '48', 
99 => 'Saturday', 
100 => 'Sat', 
101 => '04', 
102 => '4', 
103 => '12/04/2010 - 09:15', 
104 => '1291454101', 
105 => '1 hour 17 min', 
106 => '6', 
107 => array ( 0 => 'Our tours', 1 => 'Aventure', ), 
108 => array ( 0 => 'Our tours', 1 => 'Aventure', ), 
109 => 'Menu vertical', 
110 => 'Menu vertical', 
111 => 'Aventure', 
112 => 'Aventure', 
113 => '947', 
114 => '946', 
115 => 'Adventure', 
116 => 'Adventure', 
117 => '1', 
118 => 'TyulType', 
119 => 'TyulType', 
120 => '1', 
121 => array ( 0 => 'Adventure', ), 
122 => array ( 0 => 'Adventure', ), 
123 => 'taxonomy/term/1', 
124 => 'taxonomy/term/1', 
125 => array ( 0 => 'Aventure', ), 
126 => array ( 0 => 'Aventure', ), 
127 => array ( 0 => 'Aventure', 1 => 'Aventure', ), 
128 => array ( 0 => 'Aventure', 1 => 'Aventure', ), 
129 => 'Type de tioul', 
130 => 'Type de tioul', 
)
array ( 0 => '[page-title]', 
1 => '[page-title-raw]', 
2 => '[site-login]', 
3 => '[site-logo]', 
4 => '[store-name]', 
5 => '[store-url]', 
6 => '[store-link]', 
7 => '[store-owner]', 
8 => '[store-email]', 
9 => '[store-phone]', 
10 => '[store-fax]', 
11 => '[store-address]', 
12 => '[store-help-url]', 
13 => '[user-name]', 
14 => '[user-id]', 
15 => '[user-mail]', 
16 => '[site-url]', 
17 => '[site-name]', 
18 => '[site-slogan]', 
19 => '[site-mission]', 
20 => '[site-mail]', 
21 => '[site-date-yyyy]', 
22 => '[site-date-yy]', 
23 => '[site-date-month]', 
24 => '[site-date-mon]', 
25 => '[site-date-mm]', 
26 => '[site-date-m]', 
27 => '[site-date-ww]', 
28 => '[site-date-day]', 
29 => '[site-date-ddd]', 
30 => '[site-date-dd]', 
31 => '[site-date-d]', 
32 => '[site-date-small]', 
33 => '[site-date-raw]', 
34 => '[site-date-since]', 
35 => '[site-date-date]', 
36 => '[current-page-title]', 
37 => '[current-page-path-raw]', 
38 => '[current-page-path]', 
39 => '[current-page-url]', 
40 => '[current-page-number]', 
41 => '[site-date]', 
42 => '[page-number]', 
43 => '[field_photo_tyul-filefield-fid]', 
44 => '[field_photo_tyul-filefield-description]', 
45 => '[field_photo_tyul-filefield-filename]', 
46 => '[field_photo_tyul-filefield-filepath]', 
47 => '[field_photo_tyul-filefield-filemime]', 
48 => '[field_photo_tyul-filefield-filesize]', 
49 => '[field_photo_tyul-filefield-filesize_formatted]', 
50 => '[field_photo_tyul-filefield-view]', 
51 => '[field_photo_tyul-filefield-onlyname]', 
52 => '[field_photo_tyul-filefield-extension]', 
53 => '[field_circuit_link-nid]', 
54 => '[field_circuit_link-title]', 
55 => '[field_circuit_link-title-raw]', 
56 => '[field_circuit_link-link]', 
57 => '[field_circuit_link-path]', 
58 => '[field_circuit_link-url]', 
59 => '[nid]', 
60 => '[type]', 
61 => '[type-name]', 
62 => '[language]', 
63 => '[title]', 
64 => '[title-raw]', 
65 => '[node-path-raw]', 
66 => '[node-path]', 
67 => '[node-url]', 
68 => '[author-uid]', 
69 => '[author-name]', 
70 => '[author-name-raw]', 
71 => '[author-mail]', 
72 => '[author-mail-raw]', 
73 => '[log-raw]', 
74 => '[log]', 
75 => '[node_comment_count]', 
76 => '[unread_comment_count]', 
77 => '[yyyy]', 
78 => '[yy]', 
79 => '[month]', 
80 => '[mon]', 
81 => '[mm]', 
82 => '[m]', 
83 => '[ww]', 
84 => '[day]', 
85 => '[ddd]', 
86 => '[dd]', 
87 => '[d]', 
88 => '[small]', 
89 => '[raw]', 
90 => '[since]', 
91 => '[date]', 
92 => '[mod-yyyy]', 
93 => '[mod-yy]', 
94 => '[mod-month]', 
95 => '[mod-mon]', 
96 => '[mod-mm]', 
97 => '[mod-m]', 
98 => '[mod-ww]', 
99 => '[mod-day]', 
100 => '[mod-ddd]', 
101 => '[mod-dd]', 
102 => '[mod-d]', 
103 => '[mod-small]', 
104 => '[mod-raw]', 
105 => '[mod-since]', 
106 => '[mod-date]', 
107 => '[menupath]', 
108 => '[menupath-raw]', 
109 => '[menu]', 
110 => '[menu-raw]', 
111 => '[menu-link-title]', 
112 => '[menu-link-title-raw]', 
113 => '[menu-link-mlid]', 
114 => '[menu-link-plid]', 
115 => '[term]', 
116 => '[term-raw]', 
117 => '[term-id]', 
118 => '[vocab]', 
119 => '[vocab-raw]', 
120 => '[vocab-id]', 
121 => '[termpath]', 
122 => '[termpath-raw]', 
123 => '[termalias]', 
124 => '[termalias-raw]', 
125 => '[i18n-termpath]', 
126 => '[i18n-termpath-raw]', 
127 => '[i18n-term-raw]', 
128 => '[i18n-term]', 
129 => '[i18n-vocab-raw]', 
130 => '[i18n-vocab]', 
)

I'm using the patch for i18n by pokurek http://drupal.org/node/290421#comment-3763178

heyyo’s picture

Status: Fixed » Active
heyyo’s picture

Not sure if it's related but this error has appeared at the same time than this one, on Panels page only in translated language:

htmlspecialchars() expects parameter 1 to be string, array given dans /home/XXXX/sites/includes/bootstrap.inc à la ligne 857.

dalad’s picture

subscribing.

I've just updated to Token 6.x-1.15 and Pathauto 6.x-1.5 and I still see the error in the logs

gianfrasoft’s picture

I had the same problem and never found the token duplication.

I solved adding an hack code inside pathauto.inc file:

function pathauto_clean_token_values($full) {
  $replacements = array();
  foreach ($full->values as $key => $value) {
	if (is_array($value)) $value = (string)$value[0]; // <-- THIS IS THE LINE I ADDED
    // Only clean non-path tokens.
    $token = $full->tokens[$key];
    if (!preg_match('/(path|alias|url|url-brief)(-raw)?$/', $token)) {
      $replacements[$token] = pathauto_cleanstring($value);
    }
    else {
      $replacements[$token] = $value;
    }
  }
  return $replacements;
}

I simply transform the array in a string getting the first element inside of it.

I hope this may help anybody.

Bye!

dave reid’s picture

@gianfrasoft: You are not using the latest Pathauto release that accounts for some path-style tokens returning a valid array.

gianfrasoft’s picture

@Dave Reid - I'm using the latest: 6.x-1.5

dave reid’s picture

@gianfrasoft: No you're not as that function as defined in 6.x-1.5 is:

function pathauto_clean_token_values($full, $options = array()) {
  $replacements = array();
  foreach ($full->values as $key => $value) {
    $token = $full->tokens[$key];
    if (strpos($token, 'path') !== FALSE && is_array($value) && !empty($options['pathauto'])) {
      // If the token name contains 'path', the token value is an array, and
      // the 'pathauto' option was passed to token_get_values(), then the token
      // should have each segment cleaned, and then glued back together to
      // construct a value resembling an URL.
      $segments = array_map('pathauto_cleanstring', $value);
      $replacements[$token] = implode('/', $segments);
    }
    elseif (preg_match('/(path|alias|url|url-brief)(-raw)?$/', $token)) {
      // Token name matches an URL-type name and should be left raw.
      $replacements[$token] = $value;
    }
    else {
      // Token is not an URL, so it should have its value cleaned.
      $replacements[$token] = pathauto_cleanstring($value);
    }
  }
  return $replacements;
}

which has additional code to handle an array if $options['pathauto'] is TRUE.

gianfrasoft’s picture

@Dave Reid - You were right, thank you!

In my files there was a little chaos, version 1.5 of pathauto solved the problem. Bye.

gianfrasoft’s picture

Status: Active » Needs review

The problem occurred againd during a node_save API call, right using Pathauto ver. 6.x-1.5. It seems to be a curse.

I re-added the same code posted in my comment #20 and I solved again definitively.

Here is the code, again:

function pathauto_clean_token_values($full, $options = array()) {
  $replacements = array();
  foreach ($full->values as $key => $value) {
	if (is_array($value)) $value = (string)$value[0]; // <-- TAKE A LOOK AT HERE !!!!!
    $token = $full->tokens[$key];
    if (strpos($token, 'path') !== FALSE && is_array($value) && !empty($options['pathauto'])) {
      // If the token name contains 'path', the token value is an array, and
      // the 'pathauto' option was passed to token_get_values(), then the token
      // should have each segment cleaned, and then glued back together to
      // construct a value resembling an URL.
      $segments = array_map('pathauto_cleanstring', $value);
      $replacements[$token] = implode('/', $segments);
    }
    elseif (preg_match('/(path|alias|url|url-brief)(-raw)?$/', $token)) {
      // Token name matches an URL-type name and should be left raw.
      $replacements[$token] = $value;
    }
    else {
      // Token is not an URL, so it should have its value cleaned.
      $replacements[$token] = pathauto_cleanstring($value);
    }
  }
  return $replacements;
}
greggles’s picture

Status: Needs review » Closed (won't fix)

Unless it's a patch, the status should not be "needs review."

Since this fixes the symptom (noise in Pathauto) rather than the bug (buggy code in some other module) it won't be committed to Pathauto.

Please search for which module is causing the problem and file a bug with it.

dkane’s picture

I'm not sure if this provides any insight at all, but I was getting this same error (although the error was on line 441). I was also getting the following error along with it:

warning: mb_eregi_replace() expects parameter 3 to be string, array given in all/modules/pathauto/pathauto.inc on line 236. (as addressed in http://drupal.org/node/324404).

The node I was creating used the CCK field module "Phone Number" (http://drupal.org/project/cck_phone), and I found that when I disabled this module the errors went away. I'm not sure if this will shed any insight into the problem, but I figured I'd post my findings here anyway. I will also post this finding over on the "Phone Number" issues cue.

buda’s picture

I had the same problem with the Phone Number module (http://drupal.org/project/cck_phone). I tried the 6.x-1.x-dev version and the error messages had disappeared.

dave reid’s picture

@buda: Good god, the phone module provides it's tokens under the names 'raw' and 'formatted' which likely would conflict if any other token modules defines those tokens either in a node or global context. Horrible, horrible token name choices...

Please file an issue in phone.module to get those tokens properly namespaced.