Closed (fixed)
Project:
Token
Version:
8.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
16 Feb 2016 at 23:33 UTC
Updated:
27 Feb 2019 at 09:55 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
peter törnstrand commentedI'm experiencing the same problem but I'm also using the
[node:menu-link]-token on the last bit as well.My pattern looks like this:
[node:menu-link:parents:join-path]/[node:menu-link:title]On first save I just get the default
node/X"alias". On the second save the correct alias appears.Comment #3
peter törnstrand commentedChange the title to reflect that this seems not to be working regardless of what token from [node:menu-link] you use.
Comment #4
peter törnstrand commentedUpdate. Running Update URL-Alias via the content overview page does not create the missing alias. Only when saving the node form (the second time) the alias is created.
Comment #5
berdirYes, that's a known issue. See https://github.com/md-systems/pathauto/issues/76 for some background, discussion and a possible workaround.
I don't see a clean solution for this atm.
Comment #6
peter törnstrand commentedOk thanks @Berdir. The "hack module" at https://github.com/idflood/pathauto_menu_link_parents_hack solves the problem for me. It seems it would require a core fix to do this properly.
Comment #7
kevinquillen commentedThis is major IMO (to find a solution), as automating path aliasing based off menu structure is probably a common use case for automatic aliasing for most people when it comes to content.
From GitHub:
Yes. If you are aliasing content from menu paths, and change the menu structure, the alias and any below it should be checked for updates. The automation of all of this worked for me in D7 with the same tokens.
Comment #8
maartendelputte commentedI've tried to fix it myself with this code, seems to work ok:
Comment #9
rgpublicI'm still trying to figure out the reason I get this error message:
The path "/anwendungen/boden" collides with the route with identifier entity.node.canonical, whose path is /node/{node}
This happens if I clear all URL aliases and bulk generate as well as if I just save a node.
I'm also using the "infamous" pattern [node:menu-link:parents:join-path]/[node:menu-link:title]
Installing the hack module doesn't help either.
BTW: I wonder... Isn't that pattern pretty standard? It's the most intutive pattern I can think of for a hierarchically structured website... I find it confusing that this hasn't been caught yet. Without this, the whole URL alias / pathauto feature becomes almost useless. It's a major D8 show-stopper IMHO...
Comment #10
kevinquillen commentedI agree, this is the token I use for general page content (Basic Page) because 98% of it is structured in the menu tree, and I like my URLs to reflect that fact. It also makes it dead simple for a content editor to create content, put it in the menu, and get a great URL automatically without having to go to a handful of places within the admin.
The 'workarounds' posted so far mirror the same sort of ones from D6 and D7 before this token was implemented in D7. I don't want to save a node twice, that can have all sorts of implications down the road.
I haven't had time lately to really dig into this, but with all the new tools in D8 there has to be a clean solution.
Comment #11
larowlanSo here's a new approach as follows:
- create a computed ER field on node entity type that references a menu-link entity
- add an entity builder that runs on the node submit form that builds a menu-link entity and stores this in the computed field with a temporary URI (node isn't yet saved).
- after the node is saved update the URI to the correct one.
- store the saved entity ID for menu_ui module to pick up later.
- means all the tokens for node:menu-link are available (except for the path one - but no-one wants that here, because we're using pathauto to create a path, so we wouldn't reference our own path in a token) - although that will work too after #2353611: Make it possible to link to an entity by UUID is in
- only down-side I can see here is that the menu link entity is saved three times as follows:
- when the node is being built (after validation) - with the UUID based URI
- after the node is saved and the NID is known
- when
_menu_ui_node_saverunsIncludes tests.
Comment #12
larowlanComment #16
larowlanOh, also forgot to mention the other piece of the puzzle.
change menu_ui_tokens (in token module, despite the name) use the values in $node->menu_link computed field if they're present instead of using loading from the menu-tree storage
Comment #18
larowlanComment #19
berdirCan we add a comment here and reference to the test that is relying on this?
Same here, a description why we do this and a comment/todo to related core issues would be great as well. Maybe at some point core will add a similar field and I'm not sure what's going to happen then exactly.
This is also going to be one of those fields that confuse users in search api/REST/default content because it will exist but always be empty on export.
Sure about isNew? What happens if you change the menu link on an existing node? I assume that has the same problem, as the current code only looks at the currently stored data.
Comment #20
larowlan#19.1 done
#19.2 done, and changed the field description to it's clear that its only transient
#19.3 done, and added new tests - client actually reported that bug too - pretty impressed that you can pick stuff up like that straight from a review :)
Comment #23
harsha012 commentedadded patch
Comment #24
harsha012 commentedComment #27
larowlanComment #28
hussainwebRerolling #20. I am not sure what the patch in #23 was trying to do and there was no interdiff either.
Comment #29
larowlanJust a note that this doesn't work, on edit the URI is changed to node/{uuid}
Comment #30
larowlanworking on fix
Comment #31
larowlantest demonstrating the issue, with a fix
Comment #34
larowlantoo many remotes
Comment #35
Bambell commentedI manually tested #34 and the patch fixes #2, although I am not experiencing exactly the same issue. I created a "[node:menu-link:parents:join-path]/[node:menu-link:title]" pattern and created a node with a "Menu link title" and "Parent item". This would not generate an alias at all (unlike what's mentioned in #2). Going back to the node and hitting the "Save and keep published" button triggered the alias' generation. With patch #34, the alias is properly created when the node is created, so this issue seems fixed. I tested this few times.
Comment #37
berdirThanks everyone, committed.
Comment #38
larowlan:dance:
Comment #39
samtny commentedJust a note that this patch did not work until I cleared cache
drush cr.-S
Comment #40
acbramley commentedUnfortunately updating to 8.x-1.x after this was committed is giving me a bug with the menu parent selection on the node form.
I can no longer see an unpublished node's menu item in the parent item select box. Once published it shows fine.
I've tested going back and forth between versions of token and can confirm the update is what is breaking it.
The bug with the path aliases is nicely fixed however :)
Comment #41
berdirCan you create a new issue with reference to this instead?
From a quick glance, I can't see anything that would cause that, we don't mess with the available options in the menu AFAIK, but who knows..
Comment #42
acbramley commentedSure, I can't see what else changed between the two versions but I'll fire up a simplytestme to see if I can replicate it.
EDIT: Seems to be an issue with automated tests rather than the actual UI.
Comment #44
criscomLooks like this patch introduced another problem: #2769705 Menu link of default language overwritten by translations if token module installed
Comment #45
acbramley commentedAnother issue introduced here #2780423: Menu link enabled status overwritten on node form submit
Comment #46
bkosborneHeads up for anyone using the "Menu Admin per Menu" module, the fix that was committed here will likely not work for you because it checks that the user submitting the node form has the "administer menu" permission. If you're using the "Menu Admin per Menu" module, you likely don't give that permission to your editors, and instead give them the per-menu admin permissions.
Our workaround for now is to replace the entity builder with our own that does a different permission check.
Comment #47
bkosborneComment #48
chris burge commentedRe Menu Admin per Menu, take a look at #3017441: Unnecessary 'administer menu' Permission Check in token_form_node_form_alter(). The 'administer menu' check is unnecessary.
Comment #49
ayalon commentedThis change introduced several new problems. I decribed them here, if you are looking for a solution:
#3036077: Bug with menu item uuid when first save a node