diff --git a/core/includes/menu.inc b/core/includes/menu.inc index 8619448..67fb52b 100644 --- a/core/includes/menu.inc +++ b/core/includes/menu.inc @@ -2553,6 +2553,16 @@ function menu_link_get_defaults() { // Fill in the machine name from the array key. foreach ($all_links as $machine_name => &$link) { $link['machine_name'] = $machine_name; + + // Check for required array keys. + if (!isset($link['link_title'])) { + throw new \Exception(sprintf('Menu link %s does not have a "link_title" key in its definition.', $machine_name)); + } + + // Check if the specified parent menu link exists. + if (isset($link['parent']) && !isset($all_links[$link['parent']])) { + throw new \OutOfBoundsException(sprintf('Menu link %s specifies it has parent %s, but no menu link with that machine name exists.', $machine_name, $link['parent'])); + } } $module_handler->alter('menu_link_defaults', $all_links); return $all_links; diff --git a/core/modules/system/system.api.php b/core/modules/system/system.api.php index 59dfce0..1f2e63b 100644 --- a/core/modules/system/system.api.php +++ b/core/modules/system/system.api.php @@ -497,7 +497,7 @@ function hook_menu_get_item_alter(&$router_item, $path, $original_map) { * name, which must be unique. The corresponding array value is an * associative array that may contain the following key-value pairs: * - link_title: (required) The untranslated title of the menu item. - * - description: The untranslated description of the link. + * - description: (optional) The untranslated description of the link. * - route_name: (optional) The route name to be used to build the path. * Either a route_name or a link_path must be provided. * - route_parameters: (optional) The route parameters to build the path.