Set all perms available for anonymous and ound that toolbar.module throws errors because it can't find a name for anonymous users in $user->name.

Attached is a photo of the error and a patch to fix it.

Comments

zoen’s picture

StatusFileSize
new1.5 KB

This patch works and fixes the error described. Yay! However, it annoys me (usability-wise) that anonymous users get a "logout" button in their toolbar. C'mon, they're already logged as far out as they can get! Plus, it just leads to an "Access Denied" page - so useless and unfriendly. So here's a re-rolled patch that gets rid of the "logout" button for anonymous users. You like?

catch’s picture

Status: Needs review » Needs work

Confirmed both bugs, the fix isn't quite right though. I think we should just not show either of these if !$user->uid (anonymous users can't edit their accounts, $user->uid is a more robust check than $user->name).

zoen’s picture

Status: Needs work » Needs review
StatusFileSize
new1.61 KB

catch is right... Here's a new patch, that kills both the profile link and the Logout button if !$user->uid. (This stops the original error, too.)

damien tournoud’s picture

Status: Needs review » Needs work

This one should use theme('username', $user) which is specifically designed to do that.

zoen’s picture

How do you mean? Not sure how to work theme('username', $user) into this code - it will output the formatted link as a string, but the toolbar links are built as an array of titles and hrefs. Can you clarify with a code example maybe? :-)

catch’s picture

I think you can use title = theme('username'), no href, keep html => TRUE and it'll still work, but not tested this.

zoen’s picture

Status: Needs work » Needs review
StatusFileSize
new2.01 KB
new2.02 KB

Here's a new patch, using theme('username'). Note that this changes the button text from the friendly "Hello, so-and-so" to just "so-and-so".

I've also written a toolbar.test file, but I couldn't get fakeadd to work, so the test file is not rolled in the patch. catch, will you help me with that? I'm attaching the test file here. (The patch updates toolbar.info and adds toolbar.test to files[].)

Status: Needs review » Needs work

The last submitted patch failed testing.

catch’s picture

hmm, can we do t('Hello, !username' array('!username' => theme('username', $account))); maybe?

For adding files, it's usually easiest to edit CVS/Entries manually - instructions are on http://drupal.org/patch/create, don't forget to roll with cvs diff -upN

zoen’s picture

Bleh...

The CSS that gives toolbar links their positioning and padding and pretty rounded corners is based around the <a> tags. So anything not inside an <a> tag (such as our "Hello") looks isolated and misplaced. We can alter the CSS so that the pretty styles are applied to the <li>'s instead, and then the "Hello" looks well-positioned, inside the round-cornered style. But it's not nice UI: hovering over "Hello" will cause the hover style to appear for that <li>, so you feel like you're hovering over a clickable link, but the "Hello" is not linky. Only the username is clickable. We could make "Hello" itself a separate link to the user profile inside the same <li>, which would then look right and work right, but be messy and stupid on the code side. I just dunno.

I'll work on getting the .test file into my patch again later today.

casey’s picture

A lot has change since then... is this still relevant?

aspilicious’s picture

I never saw this error message...
I'm prety sure we can mark this as fixed or even closed

catch’s picture

Status: Needs work » Closed (duplicate)

No longer throws warnings. There's a little arrow for the shortcuts which doesn't do anything, but not for this issue.