Setting the Anonymous User name to something other than "anonymous" via Home » administer » configuration does not change the value on the web site, although the variable "anonymous" is set correctly in the variables table.

The problem is that when in the users table, the user's name with uid = 0 is "Anonymous", but the format_name function in common.inc doesn't acknowledge that. It expects $object->name to be NULL.

if ($object->uid && $object->name) {
  // ...
} 
else if ($object->name) {
  // code always executes here for Anonymous users
}
else {
  // this block is never reached for Anonymous users
  $output = t(variable_get("anonymous", "Anonymous"));
}

Here is the fix i purpose, but i don't know if it is the best solution. That is why i am posting it here.

if ($object->uid && $object->name) {
  // ...
} 
else if ($object->name != "Anonymous") {
  // code executes here for non Anonymous users
}
else {
  // ...
}

Comments

Dries’s picture

Assigned: Unassigned » Dries

Good catch. I just fixed this in the HEAD branch by not setting a name (and e-mail address) for the user with ID 0.

Anonymous’s picture

Automatically closed due to inactivity (marked fixed for 14 days).

Chris Johnson’s picture

Whacking the database is not a good way to fix this problem. It just introduces new ones, like "'s blog" for blog entries created by an Anonymous user (e.g. via cron from imported mail).

Now that we have UID 0 for anonymous users, ALL checks for an anonymous user should be checking against the UID, not the name.

Further, the common.inc::format_name() function is rather capricious. It arbitrarily shortens valid Drupal names to 15 letters and "..." if they are longer than 20, but accepts foreign names (from aggregators, etc.) which are not registered users of ANY length. Maybe the THEME is the right place to decide how and when to shorten any text strings.