Object of class stdClass could not be converted to string in /modules/pathauto/pathauto_node.inc on line 172.
Line 172 is $placeholders[t('[catalias]')] = drupal_get_path_alias('taxonomy/term/'.$firsttermid); however $firsttermid is an array and sometimes an object (when i transition a workflow state, it seems to change to an object, but otherwise is an array)
My ZendStudio tells me $firsttermid is $array[0]=317;
sorry for the long post but i thought ide give this some perspective!
// Use the title and other node attributes to create an alias
function node_get_placeholders($node) {
// Do the simple stuff first
$placeholders[t('[title]')] = pathauto_cleanstring($node->title);
$placeholders[t('[yyyy]')] = date('Y', $node->created);
$placeholders[t('[mm]')] = date('m', $node->created);
$placeholders[t('[mon]')] = pathauto_cleanstring(date('M', $node->created));
$placeholders[t('[dd]')] = date('d', $node->created);
$placeholders[t('[day]')] = pathauto_cleanstring(date('D', $node->created));
$placeholders[t('[hour]')] = date('H', $node->created);
$placeholders[t('[min]')] = date('i', $node->created);
$placeholders[t('[sec]')] = date('s', $node->created);
$placeholders[t('[week]')] = date('W', $node->created);
$placeholders[t('[nid]')] = $node->nid;
$placeholders[t('[type]')] = pathauto_cleanstring(node_get_name($node));
$placeholders[t('[uid]')] = $node->uid;
// Then the slightly less simple stuff
$result = db_query("SELECT name FROM {users} WHERE uid='%d'", $node->uid);
$userinfo = db_fetch_object($result);
$placeholders[t('[user]')] = pathauto_cleanstring($userinfo->name);
// Book title
if (module_exist('book') and $node->type == 'book') {
$nodebook = book_load($node);
$path = book_location($nodebook);
$placeholders[t('[book]')] = pathauto_cleanstring($path[0]->title);
$bookhierarchy = book_location($nodebook);
$bookpath = '';
foreach ($bookhierarchy as $bookelement) {
if ($bookpath == '') {
$bookpath = pathauto_cleanstring($bookelement->title);
} else {
$bookpath = $bookpath . '/' . pathauto_cleanstring($bookelement->title);
}
}
$placeholders[t('[bookpath]')] = $bookpath;
} else {
$placeholders[t('[book]')] = '';
$placeholders[t('[bookpath]')] = '';
}
// And now taxonomy, which is a bit more work
if (module_exist('taxonomy') && is_array($node->taxonomy)) {
// When editing a node, the taxonomy array might have one or more zero
// term IDs. Ignore them...
foreach ($node->taxonomy as $firsttermid) {
if ($firsttermid) {
break;
}
}
at this point, $firsttermid is an array (and sometimes an object) however taxonomy_get_term is expecting an integer
$term = taxonomy_get_term($firsttermid);
$placeholders[t('[cat]')] = pathauto_cleanstring($term->name);
$vid = $term->vid;
$vocabulary = taxonomy_get_vocabulary($vid);
$placeholders[t('[vocab]')] = pathauto_cleanstring($vocabulary->name);
once this is occurs im guessing the code is trying to append the first-term-id to the term path alias however it's appending an array (and sometimes an object) which causes the obvious failure
$placeholders[t('[catalias]')] = drupal_get_path_alias('taxonomy/term/'.$firsttermid);
if (!strncasecmp($placeholders['[catalias]'], 'taxonomy', 8)) {
$placeholders[t('[catalias]')] = $placeholders['[cat]'];
}
$catpath = '';
$parents = taxonomy_get_parents_all($firsttermid);
foreach ($parents as $parent) {
$catpath = pathauto_cleanstring($parent->name).'/'.$catpath;
}
$placeholders[t('[catpath]')] = $catpath;
} else {
$placeholders[t('[cat]')] = '';
$placeholders[t('[catpath]')] = '';
$placeholders[t('[vocab]')] = '';
$placeholders[t('[catalias]')] = '';
}
// Append any additional extensions
$extplaceholders = module_invoke_all('pathauto_node', 'values', $node);
$placeholders = array_merge($placeholders, $extplaceholders);
return $placeholders;
}
seems to be a misunderstanding of the taxonomys are cast with the node?
this is from latest 4.x dev, tagging this as critical as it could cause issues down the line, no patch just yet
Comments
Comment #1
yched commentedVery good explanation. Still true in 5.x-1.2, so bumping there.
This ($firsttermid being object/array) generates 3-4 error messages per iteration, and thus sort of floods watchdog in a cron task where I update (node_save) a large bunch of nodes.
This should "only" actually affect the generation of taxonomy-related patterns, though, so I'm not sure this is actually 'critical'.
Comment #2
gregglesis it the same problem as here: http://drupal.org/node/123001 ?
Comment #3
yched commentedyes it is - I really thought I had searched the queue :-)
Comment #4
dgtlmoon commented@greggles no this is a different issue i believe
Comment #5
yched commented@dgtlmoon : I do really think it's the same issue.
And there's a patch over there to fix the "$firsttermid is an array (and sometimes an object)" bug which pointed yourself (I did not get a chance to actually test if it solves my bug, but definitely looks like it is in the right direction)
Comment #6
dgtlmoon commentedthere was this type casting bug previously mentioned
http://drupal.org/node/155515
but the patch doesnt apply to the 4.x stream
any ideas?