diff --git a/core/modules/menu/lib/Drupal/menu/Tests/MenuLanguageTest.php b/core/modules/menu/lib/Drupal/menu/Tests/MenuLanguageTest.php index 408ca36..a2ce4a2 100644 --- a/core/modules/menu/lib/Drupal/menu/Tests/MenuLanguageTest.php +++ b/core/modules/menu/lib/Drupal/menu/Tests/MenuLanguageTest.php @@ -88,7 +88,7 @@ function testMenuLanguage() { // Check the link was added with the correct menu link default language. $menu_links = entity_load_multiple_by_properties('menu_link', array('link_title' => $title)); $menu_link = reset($menu_links); - $this->assertTrue('Menu link was found in database.'); + $this->assertTrue($menu_link, 'Menu link was found in database.'); $this->assertMenuLink($menu_link->id(), array('menu_name' => $menu_name, 'link_path' => $sample_link_path, 'langcode' => 'bb')); // Edit menu link default, changing it to cc. @@ -110,7 +110,7 @@ function testMenuLanguage() { // Check the link was added with the correct new menu link default language. $menu_links = entity_load_multiple_by_properties('menu_link', array('link_title' => $title)); $menu_link = reset($menu_links); - $this->assertTrue('Menu link was found in database.'); + $this->assertTrue($menu_link, 'Menu link was found in database.'); $this->assertMenuLink($menu_link->id(), array('menu_name' => $menu_name, 'link_path' => $sample_link_path, 'langcode' => 'cc')); // Edit menu to hide the language select on menu link item add. @@ -152,7 +152,7 @@ function assertMenuLink($mlid, array $expected_item) { $item = entity_load('menu_link', $mlid); $options = $item->options; if (!empty($options['query'])) { - $item['link_path'] .= '?' . drupal_http_build_query($options['query']); + $item['link_path'] .= '?' . \Drupal::urlGenerator()->httpBuildQuery($options['query']); } if (!empty($options['fragment'])) { $item['link_path'] .= '#' . $options['fragment']; diff --git a/core/modules/menu/lib/Drupal/menu/Tests/MenuTest.php b/core/modules/menu/lib/Drupal/menu/Tests/MenuTest.php index a5c5456..16c07c8 100644 --- a/core/modules/menu/lib/Drupal/menu/Tests/MenuTest.php +++ b/core/modules/menu/lib/Drupal/menu/Tests/MenuTest.php @@ -158,7 +158,6 @@ function addCustomMenu() { $this->assertText($label, 'Menu created'); // Enable the custom menu block. - $menu_name = 'menu-' . $menu_name; // Drupal prepends the name with 'menu-'. // Confirm that the custom menu block is available. $this->drupalGet('admin/structure/block/list/block_plugin_ui:' . config('system.theme')->get('default') . '/add'); $this->assertText($label); @@ -390,7 +389,7 @@ function addMenuLink($plid = 0, $link = '', $menu_name = 'tools', $expand $menu_links = entity_load_multiple_by_properties('menu_link', array('link_title' => $title)); $menu_link = reset($menu_links); - $this->assertTrue('Menu link was found in database.'); + $this->assertTrue($menu_link, 'Menu link was found in database.'); $this->assertMenuLink($menu_link->id(), array('menu_name' => $menu_name, 'link_path' => $link, 'has_children' => 0, 'plid' => $plid)); return $menu_link; @@ -586,7 +585,7 @@ function assertMenuLink($mlid, array $expected_item) { $item = entity_load('menu_link', $mlid); $options = $item->options; if (!empty($options['query'])) { - $item['link_path'] .= '?' . drupal_http_build_query($options['query']); + $item['link_path'] .= '?' . \Drupal::urlGenerator()->httpBuildQuery($options['query']); } if (!empty($options['fragment'])) { $item['link_path'] .= '#' . $options['fragment']; diff --git a/core/modules/menu_link/lib/Drupal/menu_link/MenuLinkFormController.php b/core/modules/menu_link/lib/Drupal/menu_link/MenuLinkFormController.php index 974ea30..9946e79 100644 --- a/core/modules/menu_link/lib/Drupal/menu_link/MenuLinkFormController.php +++ b/core/modules/menu_link/lib/Drupal/menu_link/MenuLinkFormController.php @@ -86,7 +86,7 @@ public function form(array $form, array &$form_state) { // $base_path. $path = $menu_link->link_path; if (isset($menu_link->options['query'])) { - $path .= '?' . drupal_http_build_query($menu_link->options['query']); + $path .= '?' . \Drupal::urlGenerator()->httpBuildQuery($menu_link->options['query']); } if (isset($menu_link->options['fragment'])) { $path .= '#' . $menu_link->options['fragment']; @@ -165,7 +165,13 @@ public function form(array $form, array &$form_state) { if ($menu_link->isNew()) { // Adding a new menu link, use the default from language settings config. // If no default for menu links, default to the language of the menu. - $default_langcode = (!is_null($language_configuration['langcode']) ? $language_configuration['langcode'] : $menu->langcode); + if (!is_null($language_configuration['langcode'])) { + $default_langcode = $language_configuration['langcode']; + } + else { + $menu = menu_load($menu_link->menu_name); + $default_langcode = $menu->langcode; + } } else { // Editing an already existing menu link, so use it's saved language.