In D7, whenever I go into Administration » Structure » Menus
The menu item for My account always shows "My account (disabled)"

Tried clicking the "ENABLED" check box and save, it will say changes saved but the check box will revert to being unchecked.

Why is it always disabled? Although the My account menu item does still appear under the user menu block when viewed in front end.

Thanks.

This has been going on since March 15, 2011 and it still appears in latest release of Drupal. I was unable to find another issue queue with this issue.

http://drupal.org/node/1092866

Files: 
CommentFileSizeAuthor
#43 1197622-43-tests.patch1.98 KBCottser
FAILED: [[SimpleTest]]: [MySQL] 39,392 pass(es), 2 fail(s), and 0 exception(s).
[ View ]
#43 1197622-43.patch3.65 KBCottser
PASSED: [[SimpleTest]]: [MySQL] 39,431 pass(es).
[ View ]
#39 menu-1197622-39-test-only.patch2.07 KBxjm
FAILED: [[SimpleTest]]: [MySQL] 39,870 pass(es), 2 fail(s), and 0 exception(s).
[ View ]
#39 menu-1197622-39.patch3.82 KBxjm
PASSED: [[SimpleTest]]: [MySQL] 39,873 pass(es).
[ View ]
#38 menu-1197622-38-test-only.patch2.66 KBxjm
PASSED: [[SimpleTest]]: [MySQL] 39,876 pass(es).
[ View ]
#38 menu-1197622-38.patch3.82 KBxjm
PASSED: [[SimpleTest]]: [MySQL] 39,868 pass(es).
[ View ]
#38 interdiff.txt1.1 KBxjm
#32 drupal-1197622-32-combined.patch3.55 KBlyricnz
PASSED: [[SimpleTest]]: [MySQL] 37,120 pass(es).
[ View ]
#27 drupal-1197622-27-tests.patch1.84 KBtim.plunkett
FAILED: [[SimpleTest]]: [MySQL] 37,122 pass(es), 2 fail(s), and 0 exception(s).
[ View ]
#27 drupal-1197622-27-combined.patch2.4 KBtim.plunkett
PASSED: [[SimpleTest]]: [MySQL] 37,122 pass(es).
[ View ]
#2 1197622-user-account-link.patch555 byteslyricnz
PASSED: [[SimpleTest]]: [MySQL] 34,292 pass(es).
[ View ]

Comments

twist3r’s picture

+1

lyricnz’s picture

Version:7.2» 7.x-dev
Status:Active» Needs review
StatusFileSize
new555 bytes
PASSED: [[SimpleTest]]: [MySQL] 34,292 pass(es).
[ View ]

The bug is not that saving it has no effect, but that it is not shown in the correct state.

During construction of the form, user.module modifies the "User/My account" link to be hidden for anonymous users AND when administrators editing the menu - by calling the suspiciously named user_is_anonymous(). In this case, it should be checking for real anonymous users only.

Here's a patch that checks for anonymous users directly. My only reservation is that drupal_valid_path() also calls _menu_link_translate() which ends up calling the same code - so this change could impact there.

Adam Wood’s picture

I had the same problem.

The 'My Account' link was working originally, then after building other user menu items (login/register) it disappeared.

After not being able to figure it out, I just tried hitting 'Reset' to the right of the menu item and it re-appeared!

Definitely buggy... Every time I mess with that menu it disappears again!

Hope this helps others, for now...

EDIT: I've figured out that it's when I move the 'My Account' link up or down that it gets rid of it and when I reset it, it sits under 'Log Out', which is annoying, as I want it above it!

chrislabeard’s picture

This is a really annoying problem, any fixes?

lyricnz’s picture

The patch in #2 will probably fix it for you.

marcvangend’s picture

Priority:Normal» Major
Status:Needs review» Reviewed & tested by the community
Issue tags:+d7wtf

Fix in #2 works as advertised.
I'm raising the priority to major - the patch may be tiny, but the problem it solves is a huge WTF for site administrators.

xjm’s picture

Version:8.x-dev» 7.x-dev
Priority:Normal» Major

I'm not sure this actually qualifies as major (confusing though it may be); it does not have "significant repercussions."

I think this is still NR for three reasons:

  1. I am not sure it is a good idea to check the global directly.
  2. lyricnz's comment:

    My only reservation is that drupal_valid_path() also calls _menu_link_translate() which ends up calling the same code - so this change could impact there.

  3. The api docs for user_is_anonymous():
    <?php
    function user_is_anonymous() {
     
    // Menu administrators can see items for anonymous when administering.
     
    return !$GLOBALS['user']->uid || !empty($GLOBALS['menu_admin']);
    }
    ?>

    The comment explicitly states that it's supposed to make menu items for anonymous visible to administrators. This is questionable to say the least, as @lyricnz points out.

I am wondering if we should not perhaps target the "my account" link specifically, rather than making a broad change. Maybe the whole pattern should get re-thunk for D8 and we can backport some small, specific fix to alleviate the confusion in D7.

Edit: reorganized comment for readability.

xjm’s picture

Priority:Major» Normal
Status:Reviewed & tested by the community» Needs review
xjm’s picture

Version:7.x-dev» 8.x-dev

Also, bugfixes need to go against D8 first to prevent regressions.

catch’s picture

Version:7.x-dev» 8.x-dev
Priority:Major» Normal
Issue tags:+needs backport to D7

tagging for backport.

ununpentium’s picture

+1

tinefin’s picture

+1

marcvangend’s picture

Status:Needs review» Needs work

"Needs work" is more appropriate, given the concerns in #7.

giorgio79’s picture

+1

drupalsteve’s picture

Subscribe

sebrichards’s picture

+1

infines’s picture

Why target 1 link specifically instead of just solving the issue by either the above patch or going back to the drawing board on how drupal handles links like these. This issue has been reported happening with other modules, too, so a new way for drupal to look at links like this would be the best path, imo.

infines’s picture

A solution could be to use the above patch, and then add another column to the menu administration table that has role viewing/use permissions listed.

Martin Mayer’s picture

+1

marcvangend’s picture

@Martin Mayer: "+1" or "subscribe" posts are no longer necessary. Use the follow button on the top right of the page. If you want to openly express your support for this issue, please do so by reviewing and testing patches or contributing code.

my-family’s picture

subscribe

xjm’s picture

@my-family: You don't need to post "subscribe" comments any more. There is a green "Follow" button in the upper right corner of issues that you can use instead.

Cottser’s picture

To work around this without patching, you can try creating a custom "My account" menu item pointing to user and use Menu item visibility to only show the menu item to authenticated users. Worked for me.

one_orange_cat’s picture

Thanks for this @Cottser - worked great for me and I've reposted your workaround on the related forum page.

I do think this (and others around "My account") are very visible and confusing little bugs though, unfortunately present right out of the box in D7; if possible we could really do with a quick patch-up there.

xjm’s picture

Issue tags:+Needs tests

This should be testable.

tim.plunkett’s picture

Status:Needs work» Needs review
Issue tags:-Needs tests
StatusFileSize
new2.4 KB
PASSED: [[SimpleTest]]: [MySQL] 37,122 pass(es).
[ View ]
new1.84 KB
FAILED: [[SimpleTest]]: [MySQL] 37,122 pass(es), 2 fail(s), and 0 exception(s).
[ View ]

yktdan should get credit on this patch.

lyricnz’s picture

Isn't that identical patch that was originally posted here? (but tests are good)

tim.plunkett’s picture

@lyricnz, yes, yktdan and I just worked on the tests together at NYC Camp. It was definitely your patch. I just meant that he should ALSO get credit, even though I uploaded the file.

lyricnz’s picture

I wasn't fishing for credits :) I was asking if xjm's concerns had been suitably addressed?

tim.plunkett’s picture

Haha sorry I misunderstood.

I don't think there's anything particularly wrong with using a global like that, and I think fixing user_is_anonymous is a bit out of scope for this very clearly reproducible bug.

lyricnz’s picture

StatusFileSize
new3.55 KB
PASSED: [[SimpleTest]]: [MySQL] 37,120 pass(es).
[ View ]

Agree that changing user_is_anonymous() is a bit risky, so our original proposal is OK. Even the existing comment in user_translated_menu_link_alter() describes the correct behaviour 'Hide the "User account" link for anonymous users'!

Do you think it's worth describing this special case in the UI? (adding 'logged in users only' next to the /user link)?

PS: There's an unused variable $title in _menu_overview_tree_form() - but I've left it intact to minimize the patch

lyricnz’s picture

Arguably, that UI change could be a separate patch. Happy to RTBC the functional change, and submit the UI change as a new issue.

tim.plunkett’s picture

#32 should be a follow-up, #27 should be RTBC.

xjm’s picture

Agreed about splititng off #32. Can we also get a followup for the user_is_anonymous() weirdness? I'd be okay with this being RTBC if we have a followup for that linked here.

tim.plunkett’s picture

Status:Needs review» Reviewed & tested by the community

There was already #327230: user_is_anonymous() is ugly. Great title.

xjm’s picture

Status:Reviewed & tested by the community» Needs review
StatusFileSize
new1.1 KB
new3.82 KB
PASSED: [[SimpleTest]]: [MySQL] 39,868 pass(es).
[ View ]
new2.66 KB
PASSED: [[SimpleTest]]: [MySQL] 39,876 pass(es).
[ View ]
xjm’s picture

StatusFileSize
new3.82 KB
PASSED: [[SimpleTest]]: [MySQL] 39,873 pass(es).
[ View ]
new2.07 KB
FAILED: [[SimpleTest]]: [MySQL] 39,870 pass(es), 2 fail(s), and 0 exception(s).
[ View ]

Botched the test-only patch.

warmth’s picture

Version:8.x-dev» 7.15

It's incredible that this bug is still there after 7.15 update!

tim.plunkett’s picture

Version:7.15» 8.x-dev
Status:Needs review» Reviewed & tested by the community

It would be more incredible had it not been there, since this hasn't been committed yet.

Interdiff looks good.

webchick’s picture

Version:8.x-dev» 7.x-dev
Status:Reviewed & tested by the community» Patch (to be ported)

Looks like a solid bug fix, and includes tests. Thanks!

Committed and pushed to 8.x, marking for 7.x backport.

Cottser’s picture

Status:Patch (to be ported)» Needs review
StatusFileSize
new3.65 KB
PASSED: [[SimpleTest]]: [MySQL] 39,431 pass(es).
[ View ]
new1.98 KB
FAILED: [[SimpleTest]]: [MySQL] 39,392 pass(es), 2 fail(s), and 0 exception(s).
[ View ]

Here's a backport for D7.

The only thing to note: the test was updated to look for <ul id="secondary-menu-links"> instead of <ul id="secondary-menu">.

droplet’s picture

#43: 1197622-43.patch queued for re-testing.

lyricnz’s picture

Status:Needs review» Reviewed & tested by the community

Works great. Let's put this WTF to bed.

webchick’s picture

Status:Reviewed & tested by the community» Fixed

Seems to match the 8.x patch. :)

Committed and pushed to 7.x. Thanks!

Status:Fixed» Closed (fixed)

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

marissam’s picture

warmth’s picture

Are you totally sure those are the same issue?

gpvdo’s picture

Title:My account (disabled)» My account link / menu item
Version:7.x-dev» 7.27
Issue summary:View changes
Issue tags:-needs backport to D7+needs backport to D7.27

I am testing out Drupal 7.27 for a project and have a simple issue I am not able to figure out after hours of net searching.

1. I have added my own custom menu at the top with the menu items
"Home" (path=), "Login" (path=user/login), "Register" (path=user/register), "My Account" (path=user)
and "Logout" (path=user/logout).

2. The Login/Register/Logout links work perfectly - when a user is logged in, only the "My account" and "Logout" links
are displayed, like they should be.

3. But when a user is anonymous, it displays "My account" in addition to "Login" and "Register". Why is it doing that?

4. This thread is the closest I came to with respect to this issue. Is there any way to make the "My account" not display
when a user is not logged in?

5. Note: I can move the existing link from 'User menu' to my menu and that fixes the problem.. but I'd rather not move it.

6. Related question is: In the User menu, why are only two links - 'My Account' and 'Logout' displayed instead of the four
I am expecting?

7. If this is a bug (looks like it to me), is there a patch or workaround available to fix this?

I would appreciate any help. So far I am liking Drupal a lot, but have not wandered in too deep yet..

gpvdo’s picture

I worked around the issue by simply using the built-in User-menu to begin with (rather than my own menu) and adding 'Login' and 'Create Account' links to it.

It would be nice to have both a

- 'My account' (for logged in users only), plus
- 'My account' (for all users)

that users can add to menus.