Issue #1018614 by JvE, hass, hussainweb, Niklas Fiekas, mcdruid, Pavan B S, chx, droplet, jamesharv, drupalshrek, vegantriathlete, solideogloria, aspilicious, catch, voleger, David_Rothstein, StevenPatz, mgifford: Inaccessible menu items in navigation links cause "Notice: Undefined index: localized_options"

merge-requests/756/head
mcdruid 2021-05-28 16:34:12 +01:00
parent ab6168bcd1
commit 597fbe5ee0
2 changed files with 22 additions and 1 deletions

View File

@ -1880,7 +1880,7 @@ function menu_navigation_links($menu_name, $level = 0) {
$router_item = menu_get_item();
$links = array();
foreach ($tree as $item) {
if (!$item['link']['hidden']) {
if ($item['link']['access'] && !$item['link']['hidden']) {
$class = '';
$l = $item['link']['localized_options'];
$l['href'] = $item['link']['href'];

View File

@ -294,6 +294,27 @@ class MenuTestCase extends DrupalWebTestCase {
$this->assertFieldByName('link_path', $path, 'Path no longer has query or fragment.');
}
/**
* Tries to use the navigation menu as the source for secondary links.
*/
function testNavigationAsSecondaryMenu() {
$this->drupalLogin($this->big_user);
// Go to the menu settings page and make the navigation the source for the
// secondary menu.
$edit = array(
'menu_main_links_source' => 'main-menu',
'menu_secondary_links_source' => 'navigation',
);
$this->drupalGet('admin/structure/menu/settings');
$this->drupalPost(NULL, $edit, t('Save configuration'));
// Now visit the user page. There should be an 'Add content' link in the
// navigation block and one in the secondary menu.
$this->drupalGet('user');
$this->assertNoUniqueText(t('Add content'));
}
/**
* Add a menu link using the menu module UI.
*