Problem/Motivation

Using the Linky module, when deleting a Linky entity, an exception is thrown due to menu_link_content_entity_predelete. This is due to the fact that Linky entities return the external url they are linking to as the canonical rel. When menu_link_content_entity_predelete loads that url it then calls getRouteName we get the External URLs do not have an internal route name. exception.

This was introduced by #2350797: Orphaned menu links when nodes are deleted if menu_link_ui is not enabled

Proposed resolution

Check the url is routed before calling getRouteParameters

Comments

acbramley created an issue. See original summary.

acbramley’s picture

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.4 was released on January 3, 2018 and is the final full bugfix release for the Drupal 8.4.x series. Drupal 8.4.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.5.0 on March 7, 2018. (Drupal 8.5.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.5.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.6 was released on August 1, 2018 and is the final bugfix release for the Drupal 8.5.x series. Drupal 8.5.x will not receive any further development aside from security fixes. Sites should prepare to update to 8.6.0 on September 5, 2018. (Drupal 8.6.0-rc1 is available for testing.)

Bug reports should be targeted against the 8.6.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

acbramley’s picture

Version: 8.6.x-dev » 8.8.x-dev
Issue summary: View changes
Status: Active » Needs review
Related issues: +#3012172: EntityViewBuilder::addContextualLinks assumes an entity's canonical rel is routed/internal
StatusFileSize
new3.57 KB
new2.83 KB

Status: Needs review » Needs work

The last submitted patch, 5: 2914785-5-test-only.patch, failed testing. View results

acbramley’s picture

Status: Needs work » Needs review

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.9.x-dev » 9.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

jibran’s picture

+++ b/core/modules/menu_link_content/menu_link_content.module
@@ -103,6 +103,9 @@ function menu_link_content_entity_predelete(EntityInterface $entity) {
+    if (!$url->isRouted()) {
+      continue;
+    }

Let's add a comment here to explain the reason. We can RTBC it after that.

andypost’s picture

Status: Needs review » Needs work

Test needs to fix $modules to protected https://www.drupal.org/node/2909426

hardik_patel_12’s picture

Status: Needs work » Needs review
StatusFileSize
new5.07 KB

Re-rolled the patch for 9.1.x-dev , and fixed $modules as protected.

Status: Needs review » Needs work

The last submitted patch, 12: 2914785-12.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

hardik_patel_12’s picture

Status: Needs work » Needs review
StatusFileSize
new3.46 KB
new1.29 KB

Ignore the patch at #12. Re-rolled the patch for 9.1.x-dev , and fixed $modules as protected.

acbramley’s picture

StatusFileSize
new3.59 KB
new589 bytes

Addressing #10

jibran’s picture

Status: Needs review » Reviewed & tested by the community

Thanks, for addressing the feedback. This looks ready to me.

jungle’s picture

+++ b/core/modules/menu_link_content/menu_link_content.module
@@ -104,6 +104,11 @@ function menu_link_content_entity_predelete(EntityInterface $entity) {
+    // Entities can provide uri relationships that are not routed, in
+    // this case getRouteParameters will throw an exception.

One nitpick, wrapped too early (do not exceed 80 chars)

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 15: 2914785-15.patch, failed testing. View results

acbramley’s picture

Status: Needs work » Reviewed & tested by the community

Random unrelated failure, back to RTBC

jungle’s picture

StatusFileSize
new3.59 KB
new832 bytes

Fixing #17, and stay RTBC.

jungle’s picture

StatusFileSize
new3.6 KB
new704 bytes
+++ b/core/modules/menu_link_content/menu_link_content.module
@@ -104,8 +104,8 @@ function menu_link_content_entity_predelete(EntityInterface $entity) {
+    // getRouteParameters will throw an exception.
     if (!$url->isRouted()) {

Furthermore, getRouteParameters() would be better than getRouteParameters. Keep RTBC still.

acbramley’s picture

StatusFileSize
new3.59 KB

Rolled a patch for 8.9.x

larowlan’s picture

Status: Reviewed & tested by the community » Needs work
+++ b/core/modules/system/tests/modules/entity_test/src/Entity/EntityTestExternal.php
@@ -0,0 +1,36 @@
+ *     "canonical" = "/entity_test_exteranl/{entity_test_exteranl}"

this should be external right? not exteranl

larowlan’s picture

Issue tags: +Bug Smash Initiative
mrinalini9’s picture

Version: 9.1.x-dev » 8.9.x-dev
Status: Needs work » Needs review
StatusFileSize
new3.59 KB
new572 bytes

Updated patch #22 for 8.9.x as per the changes mentioned in #23, please review.

mrinalini9’s picture

Version: 8.9.x-dev » 9.1.x-dev

By mistake changed version, reverting back.

jungle’s picture

StatusFileSize
new3.6 KB
new611 bytes

@larowlan, nice catch! Thanks

In general, patch gets committed to 9.1.x first. So uploading a patch against 9.1.x

Status: Needs review » Needs work

The last submitted patch, 27: 2914785-27.patch, failed testing. View results

jungle’s picture

Status: Needs work » Needs review

Known random failure, re-queued.

acbramley’s picture

Status: Needs review » Reviewed & tested by the community

Feedback addressed, back to RTBC!

  • larowlan committed b2a49d3 on 9.1.x
    Issue #2914785 by acbramley, jungle, Hardik_Patel_12, mrinalini9:...

  • larowlan committed 7b21f83 on 9.0.x
    Issue #2914785 by acbramley, jungle, Hardik_Patel_12, mrinalini9:...
larowlan’s picture

Title: Entities with external urls as a uri relationship can not be deleted when menu_link_content is installed » [backport] Entities with external urls as a uri relationship can not be deleted when menu_link_content is installed
Version: 9.1.x-dev » 8.9.x-dev

Committed b2a49d3 and pushed to 9.1.x. Thanks!

C/p to 9.0.x

Queuing a test-run against 8.9.x

larowlan’s picture

Status: Reviewed & tested by the community » Patch (to be ported)

Doesn't apply to 8.9.x

acbramley’s picture

Status: Patch (to be ported) » Reviewed & tested by the community
StatusFileSize
new3.62 KB

Rerolled for 8.9.x

acbramley’s picture

Patch applies cleanly with both patch -p1 and git apply for me locally after pulling the latest 8.9.x changes 🤔

acbramley’s picture

StatusFileSize
new3.62 KB

Ok, reuploading as that patch is empty!

  • larowlan committed d0e9ea0 on 8.9.x
    Issue #2914785 by acbramley, jungle, Hardik_Patel_12, mrinalini9,...
larowlan’s picture

Status: Reviewed & tested by the community » Fixed

As this is a bug and non-disruptive, backported to 8.9.x

larowlan’s picture

Title: [backport] Entities with external urls as a uri relationship can not be deleted when menu_link_content is installed » Entities with external urls as a uri relationship can not be deleted when menu_link_content is installed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.