I have a drupal6 test site where anonymous users have the permission to add/edit nodes.
If an anonymous user visits '?q=node/add/page', (s)he gets a the error message

notice: Undefined property: stdClass::$name in /home/slippens/public_html/drupal-HEAD/modules/node/node.pages.inc on line 55.

The offending line is in this function:

function node_add($type) {
  global $user;

  $types = node_get_types();
  $type = isset($type) ? str_replace('-', '_', $type) : NULL;
  // If a node type has been specified, validate its existence.
  if (isset($types[$type]) && node_access('create', $type)) {
    // Initialize settings:
55:    $node = array('uid' => $user->uid, 'name' => $user->name, 'type' => $type, 'language' => '');

    drupal_set_title(t('Create @name', array('@name' => $types[$type]->name)));
    $output = drupal_get_form($type .'_node_form', $node);
  }

  return $output;
}

attached patch uses $node->name = '' if $user->name is not set.

CommentFileSizeAuthor
anon_node_add_0.patch898 bytessoxofaan
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

soxofaan’s picture

Title: node/add by anonymous fires "notice: Undefined property" error message » node add by anonymous fires "notice: Undefined property" error message
Status: Active » Needs review
yched’s picture

Category: task » bug

should be filed a 'bug report', I guess ?

alasda’s picture

Status: Needs review » Reviewed & tested by the community

Verified issue
Applied patch
Submitted page as anonymous user
Error no longer appears
able to retrieve page content
Works as advertised.

Gábor Hojtsy’s picture

Status: Reviewed & tested by the community » Fixed

Thanks, committed.

Anonymous’s picture

Status: Fixed » Closed (fixed)

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