Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
In some kind of situations that I could not determine, the item in _custom_breadcrumbs_menu_subtree($item) is empty which results in warnings thrown by the loop.
Of course, adding a condition will fix that, but I am not sure that the item should be empty in the first place.
function _custom_breadcrumbs_menu_subtree($item) {
static $index = array();
static $indexed = array();
// This looks expensive, but menu_tree_all_data uses static caching.
$tree = menu_tree_all_data($item['menu_name']);
if (!isset($indexed[$item['menu_name']])) {
$index += _custom_breadcrumbs_menu_index($tree);
$indexed[$item['menu_name']] = TRUE;
}
// Traverse the tree.
foreach ($index[$item['mlid']]['parents'] as $mlid) { // throwing warnings
$key = $index[$mlid]['key'];
if (!isset($tree[$key])) {
return array();
}
$tree = $tree[$key]['below'];
}
$key = $index[$item['mlid']]['key'];
return isset($tree[$key]) ? $tree[$key]['below'] : array();
}
Comments
Comment #1
lamp5