Skip to content
Snippets Groups Projects
Commit 07fe4198 authored by Gerhard Killesreiter's avatar Gerhard Killesreiter
Browse files

#42388, Rehaul menu builder, patch by chx

parent 05c20c77
No related branches found
No related tags found
2 merge requests!7452Issue #1797438. HTML5 validation is preventing form submit and not fully...,!789Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
...@@ -592,31 +592,28 @@ function menu_rebuild() { ...@@ -592,31 +592,28 @@ function menu_rebuild() {
} }
} }
reset($new_items); // Save the new items updating the pids in each iteration
while (list($old_mid, $item) = each($new_items)) { while (count($new_items)) {
if ($item['pid'] < 0 && isset($new_items[$item['pid']])) { foreach($new_items as $mid => $item) {
// The item's parent has a temporary ID and is still in the queue. Put // If the item has a valid parent, save it
// the item at the back of the queue so it may be saved after the if ($item['pid'] >= 0) {
// parent item has recieved a new ID. // The new menu ID gets passed back by reference as $item['mid']
$new_items[$old_mid] = $item; menu_save_item($item);
} // Fix parent IDs for the children of the menu item just saved
else { if ($item['children']) {
// The new menu ID gets passed back by reference as $item['mid'] foreach ($item['children'] as $child) {
menu_save_item($item); if (isset($new_items[$child])) {
$new_items[$child]['pid'] = $item['mid'];
// Fix parent IDs for menu items just added. }
if ($item['children']) {
foreach ($item['children'] as $child) {
if (isset($new_items[$child])) {
$new_items[$child]['pid'] = $item['mid'];
} }
} }
// remove the item
unset($new_items[$mid]);
} }
} }
// Rebuild the menu to account for the changes.
_menu_build();
} }
// Rebuild the menu to account for the changes.
_menu_build();
} }
// Reset the cached $menu in menu_get_item(). // Reset the cached $menu in menu_get_item().
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment