Hi guys,

If we add a menu link with a query as link_path, the menu link is added to the DB but ... once added if we go to the list of links, no link appears.

Attached possible test to detect if the link is visible once added.

Cheers.

Comments

larowlan’s picture

Status: Needs work » Needs review
+++ b/core/modules/menu/lib/Drupal/menu/Tests/MenuTest.php
@@ -374,6 +374,9 @@ function testMenuQueryAndFragment() {
+    ¶

Whitespace

This should fail

catch’s picture

Priority: Critical » Major
marthinal’s picture

Status: Needs review » Needs work
StatusFileSize
new679 bytes

Attached test again.

marthinal’s picture

Uppss wrong test.

Attached again.

marthinal’s picture

Once the menu link is correctly generated and we try to edit the menu link, we've got a fail that I have fixed with this code.

-      $path .= '?' . $this->urlGenerator->httpBuildQuery($menu_link->options['query']);
+      $path .= '?' . drupal_http_build_query($menu_link->options['query']);

I have not found this method and don't know if we should implement it(httpBuildQuery) or simply use drupal_http_build_query.

The menu seems to be generated and editable as expected but I have a fail with an assertion and I need to fix it.

marthinal’s picture

Status: Needs work » Needs review
StatusFileSize
new3.76 KB

Using this patch we can add a menu link with query parameters. Also you can edit the link and remove the parameters. For example you can create a link "test?foo=bar" and rename to "test".

I was working with pwolanin who told me that it's ok to use "Url::buildQuery" to fix the problem "Call to undefined method Drupal\Core\Routing\UrlGenerator::httpBuildQuery()" when building the form.

Status: Needs review » Needs work

The last submitted patch, menu_link_query_test-2075149-6.patch, failed testing.

marthinal’s picture

Status: Needs work » Needs review
StatusFileSize
new4.67 KB

Missing use Drupal\Component\Utility\Url;

marthinal’s picture

Status: Needs review » Needs work

The last submitted patch, 8: menu_link_query_test-2075149-8.patch, failed testing.

Status: Needs review » Needs work

The last submitted patch, 8: menu_link_query_test-2075149-8.patch, failed testing.

dawehner’s picture

Issue summary: View changes
Status: Needs work » Fixed

We do know store query and fragment and use it when we render the link.

Status: Fixed » Closed (fixed)

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