Skip to content
Snippets Groups Projects
Commit 559ee07d authored by Angie Byron's avatar Angie Byron
Browse files

#473082 follow-up by sun: Remove odd breadcrumb bug workaround in menu_save().

parent c5c033dc
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
......@@ -249,8 +249,6 @@ function menu_load_all() {
* - menu_name: The unique name of the custom menu.
* - title: The human readable menu title.
* - description: The custom menu description.
* - old_name: For existing menus, the current 'menu_name', otherwise empty.
* Decides whether hook_menu_insert() or hook_menu_update() will be invoked.
*
* Modules should always pass a fully populated $menu when saving a custom
* menu, so other modules are able to output proper status or watchdog messages.
......@@ -258,7 +256,7 @@ function menu_load_all() {
* @see menu_load()
*/
function menu_save($menu) {
db_merge('menu_custom')
$status = db_merge('menu_custom')
->key(array('menu_name' => $menu['menu_name']))
->fields(array(
'title' => $menu['title'],
......@@ -267,17 +265,14 @@ function menu_save($menu) {
->execute();
menu_cache_clear_all();
// Since custom menus are keyed by name and their machine-name cannot be
// changed, there is no real differentiation between inserting and updating a
// menu. To overcome this, we define the existing menu_name as 'old_name' in
// menu_edit_menu().
// @todo Replace this condition when db_merge() returns the proper query
// result (insert/update).
if (!empty($menu['old_name'])) {
module_invoke_all('menu_update', $menu);
}
else {
module_invoke_all('menu_insert', $menu);
switch ($status) {
case SAVED_NEW:
module_invoke_all('menu_insert', $menu);
break;
case SAVED_UPDATED:
module_invoke_all('menu_update', $menu);
break;
}
}
......
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