I am getting the following error when I try to edit serveral of my CCK type nodes:

PHP Catchable fatal error: Object of class stdClass could not be converted to string in /usr/local/drupal/sites/citris/modules/modules/pathauto/pathauto_node.inc on line 170,

This is a new error introduced in PHP 5.2 (http://us3.php.net/types.string)

Here is a fix, but I am sure there is a better way to deal with it:

//    $placeholders[t('[catalias]')] = drupal_get_path_alias('taxonomy/term/'.$firsttermid);
if (!is_object($firsttermid) || method_exists($firsttermid, '__toString')) {
       $firsttermid_str = (string)$firsttermid;
} else {
       $firsttermid_str = 'Object';
}
$placeholders[t('[catalias]')] = drupal_get_path_alias('taxonomy/term/'.$firsttermid_str);

Comments

greggles’s picture

I'm having a hard time understanding where this goes - can you post it as a patch: http://drupal.org/diffandpatch ?

thanks.

starbow’s picture

It goes at line 170 of pathauto_node.inc - but I didn't submit it as a patch since it is really just a hack job that keeps the error from crashing the module rather than actually fixing the underlying issue. I suspect that the real issue is that there are some cases where $firsttermid is not being set correctly, and this bug was just being silently ignored until PHP 5.2 started complaining about it.

greggles’s picture

Status: Active » Postponed (maintainer needs more info)

What are the steps to repeat this. I'm now testing on PHP5.2 and haven't encountered this. Or is it 4.7 only? In which case I suggest upgrading to 5...

john.money’s picture

I can confirm related error when editing a CCK type node, though my linenumbers are different.

PHP 5.2.1
Drupal 5.1
Pathauto 1.1 (pathauto.module,v 1.44.2.5)

* warning: Illegal offset type in isset or empty in /home/modules/taxonomy/taxonomy.module on line 1150.
* warning: Illegal offset type in /home/modules/taxonomy/taxonomy.module on line 1151.
* warning: Illegal offset type in /home/modules/taxonomy/taxonomy.module on line 1154.
* : Object of class stdClass could not be converted to string in /home/sites/all/modules/[path]/pathauto 1.1/pathauto_node.inc on line 221.
* warning: Illegal offset type in isset or empty in /home/modules/taxonomy/taxonomy.module on line 1150.
* warning: Illegal offset type in /home/modules/taxonomy/taxonomy.module on line 1151.
* warning: Illegal offset type in /home/modules/taxonomy/taxonomy.module on line 1154.

john.money’s picture

Scratch that report... 29 April 2007 patch supplied by HorsePunchKid fixed it.

greggles’s picture

Status: Postponed (maintainer needs more info) » Closed (duplicate)

So, I guess this is a duplicate - though starbow originaly raised it for 4.7, so maybe not.

greggles’s picture

No, in fact it is still active in the 4.7 version of the module - though not on all PHP5.2 (I ran into it myself today on a site, but then can't reproduce it on my localhost).

The obvious workarounds are to use PHP4 or Upgrade to Drupal5. I don't plan to fix this.