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

+1

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.

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!

This is a really annoying problem, any fixes?

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

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.

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.

Priority:Major» Normal
Status:Reviewed & tested by the community» Needs review

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

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

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

tagging for backport.

+1

+1

Status:Needs review» Needs work

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

+1

Subscribe

+1

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.

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.

+1

@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.

subscribe

@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.

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.

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.

Issue tags:+Needs tests

This should be testable.

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.

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

@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.

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

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.

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

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

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

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.

Status:Needs review» Reviewed & tested by the community

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

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 ]

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.

Version:8.x-dev» 7.15

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

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.

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.

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">.

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

Status:Needs review» Reviewed & tested by the community

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

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.

Are you totally sure those are the same issue?