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
menu_link_content_entity_predelete()
deletes all entity URI relations, with no exception for link that do not relate to the particular entity. For example, "collection", "add-form", "add-page", etc. links.
Steps to reproduce:
- create a menu link pointing to /admin/people on any menu
- delete any user (not "disable" but "delete")
Expected result: menu link still present in the menu.
Actual result: menu link is gone.
Proposed resolution
menu_link_content_entity_predelete()
should exclude links that do not refer to the entity being deleted.
Comment | File | Size | Author |
---|---|---|---|
#8 | 2939692-8.patch | 3.4 KB | Leksat |
#3 | 2939692-3--test-only.patch | 2.13 KB | Leksat |
Comments
Comment #2
Leksat CreditAttribution: Leksat at Amazee Labs commentedComment #3
Leksat CreditAttribution: Leksat at Amazee Labs commentedComment #5
Leksat CreditAttribution: Leksat at Amazee Labs commentedHmm, according to Priority levels of issues, this should be Critical:
Even if it's not critical, it's very annoying bug because it's really difficult to catch it. For example, bug reports from customers may look like:
- menu reverts itself every 1 hour
- menu item disappeared after deployment
It took us some time to find menu_link_content_entity_predelete().
Comment #6
blazey CreditAttribution: blazey at Amazee Labs commentedWow, this is really critical. Thanks for finding and fixing @Leksat.
The bug has been reproduced on a clean drupal 8 instance. The patch fixes it. Code changes are minor and they conform to coding standards. The test is provided and targets the issue well, so moving to RTBC.
Comment #7
larowlanCan we use
$url->getParameters()
and check for a key of$entity->getEntityTypeId()
instead of using strpos?Comment #8
Leksat CreditAttribution: Leksat at Amazee Labs commented@larowlan, thanks for the hint!
Updated the patch. 2939692-3--test-only.patch is still valid.
Comment #9
blazey CreditAttribution: blazey at Amazee Labs commentedThe point has been addressed.
Comment #10
larowlanCrediting @blazey for manual testing and reproducing and myself for suggesting improvement to approach.
Comment #13
larowlanCommitted as 6029e8a and pushed to 8.6.x.
Cherry picked as 1e5c50e and pushed to 8.5.x.
Comment #15
larowlanAs this is a critical - cherry-picked as 17ebfff and pushed to 8.4.x
Comment #16
cburschkaDuplicate of #2926897: Deleting content entities also deletes collection menu items., technically; closing the other one.