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.
Problem/Motivation
When editing a menu item that has a parent menu item, if the internal path (eg, /node/123
) is entered, instead of using the entity reference autocomplete, the menu item loses it's hierarchy when caches are cleared.
Steps to reproduce:
- Add 2 nodes, in the main menu, with one under the other
- Visit the menu admin form and edit the child node
- Replace the entity reference in the path, with
node/ID
- Save the menu item
- Clear caches
- Reload the menu overview form and note that the hierarchy is gone
Proposed resolution
Figure out what's going on and fix.
Remaining tasks
User interface changes
API changes
Comment | File | Size | Author |
---|---|---|---|
#22 | 2477337-22.patch | 2.69 KB | dawehner |
#14 | menu-hierarchy-lost-2477337-14.patch | 3.33 KB | jhedstrom |
#12 | menu-hierarchy-lost-2477337-11-TEST-ONLY.patch | 2.62 KB | jhedstrom |
Comments
Comment #1
jhedstromComment #2
Wim LeersGreat catch!
Comment #3
jhedstromThis might explain part of the issue. Our hierarchy test is never run. Attached adds this test back, but it is currently failing.
Comment #4
Wim LeersLOL!
Comment #5
tim.plunkettNice. This is due to #2104123: Consolidate test methods in MenuRouterTest
Comment #7
jhedstromThis gets the test down to 1 fail (and no fatal errors), and I'm not sure if the remaining fail is actually correct or not. If we can get this green, it should probably be spun off into a separate issue rather than wait on a fix for this issue.
Comment #8
jhedstromI added #2479819: Menu hierarchy tests are not being run and am going to move this patch there, since I don't think getting these tests back in will really address this issue.
Comment #9
jhedstromComment #11
jhedstromThis test illustrates the failure. The issue has to do with menu items only being set to 'rediscover' if the uri begins with
internal
.Comment #12
jhedstromPatch above had an unnecessary call to set the 'rediscover' field.
Comment #13
jhedstromMaking this change resolves the issue, but I'm guessing it is not the ideal fix.
Comment #14
jhedstromThis fix sets rediscovery for all (I think) possible internal uris.
Comment #17
grendzy CreditAttribution: grendzy at Metal Toad commentedLooks good. These 3 URI schemes match what's defined in \Drupal\Core\Url::fromUri.
Comment #18
xjmI've just committed #2479819: Menu hierarchy tests are not being run, so triggering a retest here just to be sure.
Comment #19
catchI think we were specifically trying to avoid rediscovery for entity references - might need to check the issue history and/or profile what happens with this change.
Comment #20
tim.plunkettComment #21
dawehnerSounds like another duplicate of #2468713: Internal/custom menu links force-reset to the top of their menus on cache rebuild
This fix is certainly wrong, because route | entity already got discovered, we know their routing information. Its probably just the MenuLink code which is wrong.
Comment #22
dawehnerLet's try out a test only patch.
Comment #23
dawehnerLet's commit this test only patch, more test coverage is always good but we don't need the actual bug fix.
Comment #24
alexpottThis can't be a critical anymore.
Comment #26
alexpottCommitted 9dd19b4 and pushed to 8.0.x. Thanks!
Comment #27
alexpottComment #28
dawehnerFair point
Comment #29
sumitmadan CreditAttribution: sumitmadan at QED42 commentedCool, Not bug anymore. :)
Comment #30
alexpottAdding @sumitmadan to credit.