Index: modules/menu/menu.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/menu/menu.module,v
retrieving revision 1.227
diff -u -p -r1.227 menu.module
--- modules/menu/menu.module	14 Jan 2010 13:45:33 -0000	1.227
+++ modules/menu/menu.module	14 Jan 2010 17:27:51 -0000
@@ -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;
   }
 }
 
