It would appear that the error message...

Notice: Undefined property: stdClass::$name in theme_chatroom_message_username() (line 852 of C:\inetpub\wwwroot\Stream\Drupal7\sites\all\modules\chatroom\chatroom.module).

shows when an anonymous user interacts with the chat, 1 notice received for every 1 anonymous chat comment.

It would appear that theme_chatroom_message_username() in chatroom.module is calling the function function drupal_anonymous_user() which returns some user info.. http://api.drupal.org/api/drupal/includes!bootstrap.inc/function/drupal_...

The info returned however does not contain the username for which is required when building the $info array that is looking for $chat_user->name.

function theme_chatroom_message_username($variables) {
  $chat_user = $variables['message']->uid ? user_load($variables['message']->uid) : drupal_anonymous_user();
  $output = '<span class="chatroom-message-username">';
  $info = array(
    'account' => $chat_user,
    'name' => $chat_user->name,
    'extra' => '',
    'link_path' => 'user/' . $chat_user->uid,
    'link_options' => array(),
  );
  $output .= theme('username', $info);
  $output .= '</span>';
  return $output;
}

This works fine for signed in members but does not anonymous.

CommentFileSizeAuthor
#2 username_theme_error-1993674-2.patch794 bytesglekli
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

ancym’s picture

+1

glekli’s picture

Issue summary: View changes
Status: Active » Needs review
FileSize
794 bytes

Attaching a patch to fix this. I think using format_username() is the proper solution here.

glekli’s picture

Status: Needs review » Fixed

glekli’s picture

Title: Notice: Undefined property: stdClass::$name in theme_chatroom_message_username() - line 852 of chatroom.module » Error when displaying username for anonymous

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.