Catchable fatal error: Object of class stdClass could not be converted to string in .../modules/token/token.module on line 190

Sorry, no patch - I'm remoted into a foreign system that's decided to use SVN instead ... :-(

Anyway, the existing code below:

function ogactivity_token_values($type, $data = NULL, $options = array()) {
  static $authors;
  if ($type == 'ogactivity' && !empty($data)) {
    if (!isset($authors[$data['author-uid']])) {
      $user = db_fetch_object(db_query('SELECT uid, name FROM {users} WHERE uid = %d',  $data['author-uid']));
      $authors[$data['author-uid']] = theme('username', $user);
    }
    $data['author-name'] = $authors[$data['author-uid']];
  }
  return $data;
}

... will return a full $node object as the token value when token_get_values() invokes module_invoke_all('token_values', 'node', $node);
... this results is a horrible $node object in the list of strings.
I modified it to :

function ogactivity_token_values($type, $data = NULL, $options = array()) {
  static $authors;
  if ($type == 'ogactivity' && !empty($data)) {
    if (!isset($authors[$data['author-uid']])) {
      $user = db_fetch_object(db_query('SELECT uid, name FROM {users} WHERE uid = %d',  $data['author-uid']));
      $authors[$data['author-uid']] = theme('username', $user);
    }
    $data['author-name'] = $authors[$data['author-uid']];
    return $data;
  }
}

... shifting the return into the case where there actually is something to return.

... Sorry, I can't actually figure what version this is on (not my site, just troubleshooting). Something in Drupal 5.
$Id: token.module,v 1.5.2.12 2008/01/17 10:46:16 greggles Exp $
. Huh. That's old. Feel free to ignore it, looks like it can't have been bothering anyone else for a year. Or it's fixed in one of the various dev versions.
Maybe it only shows up with strict warnings.

Comments

sirkitree’s picture

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

HOOK_token_values() must return array of strings (the token values).
As it stands, if $type does NOT = 'ogactivity' , if $type = 'node' , then ogactivity_token_values returns a $node object instead!
This ruins the $token array and triggers casting errors in later token processing.

sirkitree’s picture

Status: Postponed (maintainer needs more info) » Closed (won't fix)

5.x unsupported please see 6.x-2