Problem/Motivation

Install drupal in a subfolder, edit the administration menu (admin/structure/menu/manage/admin) and use the 'Add link' local action to create a custom menu link. Click Save and you get an error:
The requested page "/drupal/admin/structure/menu/manage/admin" could not be found.

Proposed resolution

Use system path as destination.

Remaining tasks

review

User interface changes

none

API changes

none

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

The last submitted patch, menu_add_edit_delete_links-fail.patch, failed testing.

Status: Needs review » Needs work

The last submitted patch, menu_add_edit_delete_links.patch, failed testing.

olli’s picture

Status: Needs work » Needs review
FileSize
1.51 KB
3.37 KB
785 bytes

Another try.

The last submitted patch, 3: menu_add_edit_delete_links-fail.patch, failed testing.

olli’s picture

Issue summary: View changes
dawehner’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: +MenuSystemRevamp

Oh, I really wanted to have a look at that

+++ b/core/modules/menu_ui/src/Plugin/Menu/LocalAction/MenuLinkAdd.php
@@ -30,7 +30,7 @@ public function getOptions(Request $request) {
       // @todo Use RouteMatch instead of Request.
       //   https://www.drupal.org/node/2294157

Do we really still need this todo here? OT

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 3: menu_add_edit_delete_links.patch, failed testing.

olli’s picture

Status: Needs work » Needs review
FileSize
3.38 KB
1.07 KB
dawehner’s picture

Mh, why aren't all strings available as the title?

olli’s picture

FileSize
3.37 KB
1.08 KB

They should be.

dawehner’s picture

Status: Needs review » Reviewed & tested by the community

True!

alexpott’s picture

Status: Reviewed & tested by the community » Needs work
  1. +++ b/core/modules/menu_ui/src/MenuForm.php
    @@ -305,7 +305,7 @@ protected function buildOverviewTreeForm($tree, $delta) {
    -          $operations['edit']['query']['destination'] = $this->entity->url();
    +          $operations['edit']['query']['destination'] = $this->entity->getSystemPath();
    

    How are we going to help people not make this mistake in the future - would seem a really easy thing to get confused.

  2. +++ b/core/modules/menu_ui/src/Plugin/Menu/LocalAction/MenuLinkAdd.php
    @@ -30,7 +30,7 @@ public function getOptions(Request $request) {
    -      $options['query']['destination'] = \Drupal::urlGenerator()->generateFromRoute($route_name, $raw_variables);
    +      $options['query']['destination'] = \Drupal::urlGenerator()->getPathFromRoute($route_name, $raw_variables);
    

    getPathFromRoute() is marked for deprecation.

olli’s picture

Status: Needs work » Needs review

Good points..
#12.1 - Are you suggesting that there might be a bug RedirectResponseSubscriber::checkRedirectUrl() because it redirects to an invalid internal path?
#12.2 - I have no idea what to use there instead.. even that checkRedirectUrl() uses it.

We still have drupal_get_destination(), which is not deprecated and might work in both cases...

olli’s picture

FileSize
4.22 KB
2.72 KB

#12.1 That ::getSystemPath is also deprecated. Here's a patch with drupal_get_destination().

+++ b/core/modules/menu_ui/src/MenuForm.php
@@ -390,15 +390,15 @@ protected function buildOverviewTreeForm($tree, $delta) {
-        if ($link->isResettable()) {
+        if ($link->isResettable()->isAllowed()) {

Filed #2373017: No delete link when editing a menu, only reset links for this.

Berdir queued 14: 2313263-14.patch for re-testing.

Status: Needs review » Needs work

The last submitted patch, 14: 2313263-14.patch, failed testing.

dawehner’s picture

Issue tags: +Needs reroll
+++ b/core/modules/menu_ui/src/Plugin/Menu/LocalAction/MenuLinkAdd.php
@@ -21,17 +21,7 @@ class MenuLinkAdd extends LocalActionDefault {
-    // Append the current path as destination to the query string.
-    if ($request->attributes->has(RouteObjectInterface::ROUTE_NAME)) {
-      $route_name = $request->attributes->get(RouteObjectInterface::ROUTE_NAME);
-      $raw_variables = array();
-      if ($request->attributes->has('_raw_variables')) {
-        $raw_variables = $request->attributes->get('_raw_variables')->all();
-      }
-      // @todo Use RouteMatch instead of Request.
-      //   https://www.drupal.org/node/2294157
-      $options['query']['destination'] = \Drupal::urlGenerator()->generateFromRoute($route_name, $raw_variables);
-    }
+    $options['query']['destination'] = drupal_get_destination()['destination'];

This is certainly much better. Ideally drupal_get_destination() could use something like internally, but well, that is out of scope of this issue.

olli’s picture

Status: Needs work » Needs review
Issue tags: -Needs reroll
FileSize
1.52 KB
3.45 KB
651 bytes

Here's a reroll.

olli’s picture

How do I get the system path/set destination if I need to use something else than current path?

The last submitted patch, 18: 2313263-18-test_only.patch, failed testing.

idebr’s picture

Priority: Normal » Major
Related issues: +#2395189: Deletion of menu link results in error

This patch also fixes #2395189: Deletion of menu link results in error, so bumping to major.

How do I get the system path/set destination if I need to use something else than current path?

The edit and delete links for menu items are currently hardcoded to return back to the overview page. Does this question apply to this issue?

kgoel’s picture

FileSize
3.58 KB
1.81 KB
kgoel’s picture

Issue tags: +D8 Accelerate NJ

Status: Needs review » Needs work

The last submitted patch, 22: 2313263-22.patch, failed testing.

pwolanin’s picture

Thanks for fixing the tests to use routes.

The continued use of drupal_get_destination() is a bit frustrating, but I think it's the best we have right now.

Possibly should move this logic at least to the RouteMatch?

idebr’s picture

The alternative would be to make ConfirmFormHelper::buildCancelLink to accept urls instead of uris.

Note: this already works for form redirects/destination urls

kgoel’s picture

FileSize
3.54 KB
1.95 KB
kgoel’s picture

Status: Needs work » Needs review
pwolanin’s picture

Status: Needs review » Reviewed & tested by the community

Thanks. We need to make a replacement for drupal_get_destination() and/or fix the way the destination query string works, but that's beyond the scope of this patch.

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

This issue addresses a major bug and is allowed per https://www.drupal.org/core/beta-changes. Committed 7816819 and pushed to 8.0.x. Thanks!

Yep drupal_get_destination() does seem out-of-place. Also how are we going to ensure people don't make this mistake in contrib?

  • alexpott committed 7816819 on 8.0.x
    Issue #2313263 by olli, kgoel: Page not found after adding, editing or...

Status: Fixed » Closed (fixed)

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