Quantcast
Channel: Issues for Drupal core
Viewing all articles
Browse latest Browse all 292987

Menu UI searchs links by incorrect uri

$
0
0

Problem/Motivation

"menu_ui_get_menu_link_defaults()" doesn't consider the default menu in parent menu when we have two menu link items pointing to same node.

Steps to reproduce

Add a new menu
Add the new menu to the Article content type.
Add a new article
Add a menu link into the new menu
Add a menu link into the main navigation.
Go to the edit form for the article. The main menu link should be the default, but the menu link from the new menu is.

Steps taken from #21

Proposed resolution

Use valid URI entity:node/ in the query

Remaining tasks

Needs review from committer.

User interface changes

N/A

API changes

N/A

Data model changes

N/A

Release notes snippet

N/A

Original report by AndreyMaximov

There is incorrect query in function menu_ui_get_menu_link_defaults() that never returns results.

function menu_ui_get_menu_link_defaults(NodeInterface $node) {
  //...
  // Give priority to the default menu
  $type_menus = $node_type->getThirdPartySetting('menu_ui', 'available_menus', array('main'));
  if (in_array($menu_name, $type_menus)) {
    $query = \Drupal::entityQuery('menu_link_content')
      ->condition('link.uri', 'node/' . $node->id())
      ->condition('menu_name', $menu_name)
      ->sort('id', 'ASC')
      ->range(0, 1);
    $result = $query->execute();

entity: scheme is missed.
The fix is pretty simple:

  ->condition('link.uri', 'node/' . $node->id())

should become

  ->condition('link.uri', 'entity:node/' . $node->id())

The bug results in extra query executed when a node edit page is opened.


Viewing all articles
Browse latest Browse all 292987

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>