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.
The commit from this issue was reverted in #3162806: Revert introduction of UUID entity path for menu links from #2353585..
People who need better support for menu links should check out Features menu UUID.
Hi!
Read more about the problem at http://www.drupal.org/node/968826
I've found an other issue before the rewrite, but that was written for Features 1.x.
You can export menu items linking to Nodes, Terms, and Users, and deploy them on an other site or installation.
You will need the UUID module in order to get it working.
Comments
Comment #1
imre.horjanI've written a patch, which exports menu links using UUIDs for Features version 2.x-dev.
The modifications was originally written for version 2.3, but ported a patch to the dev version.)
Comment #2
imre.horjanChanging the status to Needs review
Comment #3
imre.horjanComment #4
imre.horjanComment #5
imre.horjanHere's a modified patch file.
The code in the previous patch didn't correctly identify the imported / existing menu items, so menu items were created multiple times on consecutive feature reverts.
This is fixed. Already imported / existing menu items will be identified and won't be created multiple times.
There's a side effect using this patch:
Menu items compontent will always be in the 'Overriden" state.
That's because uuid paths are used in exported module code, while internal paths are set up for menu items in the database. Features diff identifies that as a manual override.
Comment #6
JurriaanRoelofs CreditAttribution: JurriaanRoelofs commentedThanks! I tried the patch and it succesfully imported menu links as part of my distribution profile.
What is odd though is that imported menu links do not get added during profile installation. It might be relevant that the menu links and the content that is linked are in the same feature module, so maybe the menu link features fails initially because the content is not added yet, or maybe a cache clear is needed after the content is added, before the links are added.
Using a little hack in my feature module's install file the import of menu links is completed after profile installation:
Comment #7
JurriaanRoelofs CreditAttribution: JurriaanRoelofs commentedmajor issue: after adding menu links to a feature the frontend menu actually links to a uuid path instead of a pathauto path. this is not good for SEO and not an option for existing sites.
update: I see I didnt have this problem on the site to which I exported the feature and the difference I noticed was the feature being enabled on the latter and disabled on the former site. When I enable the feature on the source site the menu links turn back to normal
Comment #8
imre.horjanHi Jurriaan!
As far as I understand it works fine if you enable the exported feature module.
Menu items are exported using the UUID path, however in some cases the UUID path couldn't be resolved to an internal path (for example you forgot to export the corresponding node or it's in a module which is reverted later).
In this case the menu item will be created using the UUID path. I think it's better than skipping / hiding the menu item.
The problem you mentioned in #6 might be because components handled by Features itself are reverted before other contrib module components (like UUID nodes).
I think the best solution would be to refactor the code from Features module into UUID Features module.
When I started to write the code, it was easier to start with Features than UUID Features.
Comment #9
JurriaanRoelofs CreditAttribution: JurriaanRoelofs commentedI've rebuilt my menu and been spending all day trying to make it work but this is what happens:
1. Menu is fine
2. I add menu links to a feature and export it
3. The menu_links table gets updated, replacing my node links with uuid links, setting router path from node/% to uuid and setting the link_path to uuid too, making my menu turn into a uuid mess on the frontend.
update: I just noticed that if I revert the feature with the (bodged) menu links, the menu is back to normal. I have to delete a menu item before reverting otherwise it will show "default" status. I'm hoping it will stay working now but I still recommend anyone using this code to backup your database (often) when playing around.
Comment #10
imre.horjanBacking up the database before trying untrusted code is a good practice.
Jurr, it would be nice to know whether you started working with patch #1, or you got involved with patch #5.
UUID paths are replaced by it's internal paths by revert.
If you find any menu item not working fine, simply delete it, and the next revert will create it right.
You may be right regarding router paths.
When you export a feature module the link path is set to the UUID path of the target entity, and router path is set to 'uuid'.
When reverting that feature UUID paths are replaced by the internal path, and the router path should also be set back to 'node/%' for example. This may not work correctly.
I need some time to check and fix that.
Comment #11
imre.horjanThis comment is posted twice accidentally.
Comment #12
JurriaanRoelofs CreditAttribution: JurriaanRoelofs commentedHi, I used the patch in comment #5, I'll post back when I will work on my menu links feature again and see if I can figure out if reverting fixes the problem
Comment #13
hswong3i CreditAttribution: hswong3i commentedI am now applying #5 for DruStack http://cgit.drupalcode.org/drustack/commit/?id=b722665
Will report if error happened ;-)
Comment #14
imre.horjanWe still have some problems.
The patch works in an automated deployment environment, in which case you export features on one site, and revert them on the other, but causes problems when you export and revert them on the same site.
When you export, your menu paths are changed unexpectedly, so you always need to revert after export.
Comment #15
mattsqd CreditAttribution: mattsqd at FFW commentedI worked off of #5 to allow UUIDs to always stay in the info file instead of reverting back to node IDs.
Comment #16
mattsqd CreditAttribution: mattsqd at FFW commentedAdded another missing section where a link was loaded but uuid path not added for parent_identifier.
Comment #17
mattsqd CreditAttribution: mattsqd at FFW commentedComment #18
mattsqd CreditAttribution: mattsqd at FFW commentedFound another issue where the uuid link was saved instead of the internal link so links were not displaying correctly.
Comment #19
kenorb CreditAttribution: kenorb commentedComment #20
bohemier CreditAttribution: bohemier commentedThanks for the patch. It worked for me. I was able to export nodes and menu items and import them back in another site with different node ids.
Comment #21
hswong3i CreditAttribution: hswong3i commentedRevoke from #18 + code cleanup with coder + patch via latest 7.x-2.x
Comment #22
JurriaanRoelofs CreditAttribution: JurriaanRoelofs commentedgreat work hswong3i.
I still have the prolbem of UUID Redirector showing on pages as a breadcrumb component. This is in nodes where the menu tree is used to generate breadcrumbs.
Any way to fix that?
Comment #23
nvahalik CreditAttribution: nvahalik as a volunteer commentedShouldn't this be a part of the UUID features module? It seems odd to include it here.
Comment #24
nvahalik CreditAttribution: nvahalik as a volunteer commentedDon't include non-relevant code formats in your patch. It adds bulk to the patch and makes it harder to review.
Comment #25
nvahalik CreditAttribution: nvahalik as a volunteer commentedAlso, my suggestion is to re-roll this patch into UUID Features. There is no other UUID-related code in this module and I doubt they will want to add it since there is already a module that handles that functionality anyway.
Comment #26
imre.horjanHi nvahalik and others,
I'm not up-to-date with the status of this patch. We are still using the #5 patch in production without problems.
Yes it should be part of UUID features instead of features module, but it won't be an easy job (see my comment #8 above).
Feel free to refactor into that module if you have time for that.
The refactor may also solve some unexpected results.
Comment #27
shakarins CreditAttribution: shakarins commentedThank you everybody, this patch has been very useful for me, but now I have the same problem than #22.
JurriaanRoelofs, have you found any solution for the breadcrumb issue?
Comment #28
hswong3i CreditAttribution: hswong3i commentedJust simply reroll #21 via latest 7.x-2.x changes.
(Well, sorry that I will not put else improvement effort for D7, just some simple maintenance duty)
Comment #29
joseph.olstadI pushed a commit today that conflicts with patch 28.
Here's the reroll.patch 28 is good for the release features 7.x-2.11patch 29 works for the latest dev branch 7.x-devComment #30
joseph.olstadfixing regression in patch 29,
here's patch 30
I pushed a commit to the 7.x-2.x branch today that conflicts with patch 28.
Here's the reroll.
patch 28 is good for the release features 7.x-2.11
patch 30 works for the latest dev branch 7.x-dev
Comment #32
joseph.olstadfixed in 7.x-2.x dev
Comment #33
joseph.olstadFor any related regressions such as the breadcrumb issue, please open a new issue and put a link to it here.
It is likely that some of these issues noted above have been fixed by other issues.
In any case, open a new issue and link it here as mentioned.
Comment #34
hswong3i CreditAttribution: hswong3i commented@joseph.olstad thank you very much ~~~
P.S. I just guess this issue may forever as a patch living inside my composer.json since #13 ;-P
Comment #36
ciss CreditAttribution: ciss at yousign GmbH commented@joseph.olstad The committed patch introduced some nasty code duplication into the code base (4x functionally equivalent code) and should be refactored into a helper function. Should I attach a follow-up patch to this issue or create a new one?
Duplicate code:
Comment #37
donquixote CreditAttribution: donquixote commented@ciss (#36)
Thanks for pointing this out!
I suggest to open a new issue and then link between them.
Comment #38
joseph.olstad@ciss, please post the patch here or to a new issue and please add a link to that issue here so that I am notified.
Comment #39
ciss CreditAttribution: ciss at yousign GmbH commented@donquixote @joseph.olstad Created #3085880: Revisit UUID handling for menu links as follow-up.
Comment #40
donquixote CreditAttribution: donquixote commentedRevert in #3162806: Revert introduction of UUID entity path for menu links from #2353585. before next release.
Explanations there.
Comment #41
donquixote CreditAttribution: donquixote commented