Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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'];
Comment | File | Size | Author |
---|---|---|---|
#7 | Screenshot 2016-03-07 11.14.59.png | 72.58 KB | nelslynn |
Comments
Comment #1
dealancer CreditAttribution: dealancer commentedIt 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.
Comment #2
vesselin CreditAttribution: vesselin commentedI 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".
Comment #3
dealancer CreditAttribution: dealancer commentedLooks like it needs work.
Comment #4
DevElCuy CreditAttribution: DevElCuy commentedIt needs a deep test on PostgreSQL, any volunteer?
Comment #5
mradcliffeuser/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.
Comment #6
mradcliffeThe issue in menu_token is in the item access checking.
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.
Comment #7
nelslynn CreditAttribution: nelslynn commentedCan 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.
Comment #8
DevElCuy CreditAttribution: DevElCuy at Dilygent commented