I just tried to save a new menu link using an alias. I got the following message:

The menu system stores system paths only, but will use the URL alias for display. foooo has been stored as node/1
The menu link has been saved.

Unfortunately, contrary to the displayed message, the menu link was not saved.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

larowlan’s picture

Issue tags: +Needs tests

Adding tag

larowlan’s picture

grep -ir "but will use the URL" core
core/modules/menu_link/lib/Drupal/menu_link/MenuLinkFormController.php:      drupal_set_message(t('The menu system stores system paths only, but will use the URL alias for display. %link_path has been stored as %normal_path', array('%link_path' => $menu_link->link_path, '%normal_path' => $normal_path)));

Definitely no test coverage

marthinal’s picture

Status: Active » Needs review
FileSize
925 bytes

Hi guys,

The problem is when submitting the form, we generate an entity using the form values. Maybe we should alter the form_state value?

Cheers.

marthinal’s picture

If we have query parameters the patch doesn't work because we are adding values to the $menu_link object into the validation.

larowlan’s picture

We still need tests here

marthinal’s picture

Status: Needs review » Needs work

I think the place to detect this is from MenuTest.php where we add/remove menu links. I was trying today on a break, but I need more time.

When adding the new path with a query, the path is added complete to the "link_path" and to reproduce the same behavior as D7 does, the query should be added to "options" as I can verify.

So I change the status to needs work.

andymartha’s picture

FileSize
48.86 KB
49.47 KB

After applying the patch 2063191-menulinks.patch by marthinal in #3 to a Drupal 8 fresh install 8/17, adding a menu link from an alias, which was previously not saving, is now saving to the menu.
2063191before1.png

2063191after1.png

larowlan’s picture

Assigned: Unassigned » larowlan

adding tests

larowlan’s picture

Title: menu items do not save if the menu path is an alias. » Menu items do not save if the menu path is an alias.
Assigned: larowlan » Unassigned
Status: Needs work » Needs review
Issue tags: -Needs tests
FileSize
2.94 KB
2.18 KB

Adds tests.
Should be red/green

marthinal’s picture

FileSize
2.05 KB

@larowlan Seems to work as expected with a query using this patch.

Thanks for the test. I was starting the test when I saw your test :)

Status: Needs review » Needs work

The last submitted patch, 2063191-menulinks-10.patch, failed testing.

larowlan’s picture

Assigned: Unassigned » larowlan

Working on passing patch

larowlan’s picture

Assigned: larowlan » Unassigned
Status: Needs work » Needs review
FileSize
4.6 KB
2.42 KB

Fixes test fail at #9
Interdiff is against 9.

larowlan’s picture

Less fragile test, doesn't rely on node/5

larowlan’s picture

So @marthinal are you saying we need to handle links to aliases with parameters as well? eg foobar?bar=baz which is an alias to node/1?bar=baz ?

manumilou’s picture

I was able to reproduce the bug. Patch #14 fixed it. See screenshots attached.

SheilaSmith’s picture

got the same issue,I just tried and it helped. thanks :)

thedavidmeister’s picture

Status: Needs review » Reviewed & tested by the community

we have 5 reports that this works with screenshots for 2, test coverage, I don't see any coding standards issues, this looks RTBC then.

catch’s picture

Status: Reviewed & tested by the community » Fixed

Committed/pushed to 8.x, thanks!

Status: Fixed » Closed (fixed)

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

SweetTomato’s picture

I'm getting this in Drupal 7. Will there be a patch for 7?

matt.rad’s picture

Issue summary: View changes

Also having this problem in D7. I would appreciate a patch too.

cilefen’s picture

harshadananjaya’s picture

Please check your linked content page is published or not?