This should do the trick and remove tokens that have not been successfully substituted.

      $item['link_path'] = strtolower(str_replace(' ', '-', token_replace($menu_token_enabled[$mlid], array('global'))));
+    //token still present remove it via access..
+    if (count(token_scan($item['link_path'])) > 0) {
+       $item['access'] = FALSE;
+       return;
+     }
       $item['href'] = $item['link_path'];
CommentFileSizeAuthor
#7 Screenshot 2016-03-07 11.14.59.png72.58 KBnelslynn
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

dealancer’s picture

Category: bug » feature

It is validated automatically by menu subsystem.

However we need to add optional feature to validate Menu Item title. Validation should be enabled by default, but user should be allowed to disable it. So we need to have checkbox with a text 'Do not hide menu item if link title contains unprocessed token'.

Changing issue status to feature request.

vesselin’s picture

Category: feature » bug

I think it should actually be a bug and this is a critical issue with PostgreSQL. When the URL is something like:
user/[current-user:uid]/edit
and the user is not logged in, then on Drupal 7 it will expand to:
user/not yet assigned/edit

Then the menu system will try to load user with UID "not yet assigned" and on PostgreSQL it will crash with "Invalid text representation".

So this is actually a bug and not just a feature request, at least for those of us who use PostgreSQL.

Actually after trying the patch, it seems that just scanning the text for unreplaced tokens doesn't fix the issue, because [current-user:uid] does get replaced with "not yet assigned".

This issue seems to be related to the one listed here:
http://drupal.org/node/1003788
Applying the patch from #71 does fix the PostgreSQL crash caused by the use of [current-user:uid] with anonymous user sessions. However it is just a workaround and not a real fix. I think that there should be a way to avoid replacing [current-user:uid] with "not yet assigned".

dealancer’s picture

Status: Needs review » Needs work

Looks like it needs work.

DevElCuy’s picture

Issue tags: +PostgreSQL

It needs a deep test on PostgreSQL, any volunteer?

mradcliffe’s picture

user/user.tokens.inc adds a translated replacement of "not yet assigned".

PostgreSQL has strict typing unlike MySQL, which will try to run a query with mismatch column data type. This can be see in some recent core issues like #2056627: Form API autocomplete is broken for routes and #1831846: Help block is broken with language path prefixes, which silently fail in MySQL but not in PostgreSQL.

mradcliffe’s picture

The issue in menu_token is in the item access checking.

// Line 160 of 7.x-1.x branch.
// $url = 'user/not yet assigned/edit'
if ($menu_item = menu_get_item($url)) {

This is a core bug (need to look this up). If I go to "user/not yet assigned" manually, then it does the same thing.

nelslynn’s picture

Issue summary: View changes
FileSize
72.58 KB

Can someone please update the status of this issue? How do you configure a user link to not show for anonymous users?

For example:
[site:url]user/[current-user:uid]/wishlist or just user/[current-user:uid]/wishlist will show for anonymous users with a URL of: http://mysite.com/user/not%20yet%20assigned/wishlist

This token: [current-user:url] works great. The link does not display for anonymous users.

I've tried every possible configuration. I also cannot find the code in #1 to replace.

DevElCuy’s picture

Status: Needs work » Closed (outdated)