? 526756-save-book.patch
? 526756-save.patch
Index: menu_node.install
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/menu_node/menu_node.install,v
retrieving revision 1.1
diff -u -p -r1.1 menu_node.install
--- menu_node.install	8 May 2009 14:00:16 -0000	1.1
+++ menu_node.install	12 Aug 2009 19:15:43 -0000
@@ -42,11 +42,12 @@ function menu_node_uninstall() {
  */
 function menu_node_enable() {
   $items = array();
-  $result = db_query("SELECT mlid, link_path FROM {menu_links} WHERE link_path LIKE 'node/%' AND router_path = 'node/%%'");
+  $result = db_query("SELECT ml.mlid, ml.link_path FROM {menu_links} ml INNER JOIN {menu_custom} mc ON ml.menu_name = mc.menu_name WHERE ml.link_path LIKE 'node/%' AND ml.router_path = 'node/%%'");
   while ($data = db_fetch_object($result)) {
     $nid = str_replace('node/', '', $data->link_path);
     // Ensure that we did not grab any bad links accidentally.
-    if (is_numeric($nid)) {
+    $check = (bool) db_result(db_query("SELECT COUNT(*) FROM {node} WHERE nid = %d", $nid));
+    if ($check) {
       db_query("INSERT INTO {menu_node} (nid, mlid) VALUES (%d, %d)", $nid, $data->mlid);
     }
   }
@@ -60,3 +61,17 @@ function menu_node_enable() {
 function menu_node_disable() {
   db_query("DELETE FROM {menu_node}");
 }
+
+/**
+ * Update function to remove book module entries.
+ */
+function menu_node_update_6000() {
+  $ret = array();
+  if (module_exists('book')) {
+    $result = db_query("SELECT mlid, nid FROM {book}");
+    while ($data = db_fetch_object($result)) {
+      menu_node_delete($data->nid, $data->mlid);
+    }
+  }
+  return $ret;
+}
Index: menu_node.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/menu_node/menu_node.module,v
retrieving revision 1.2
diff -u -p -r1.2 menu_node.module
--- menu_node.module	26 May 2009 15:19:15 -0000	1.2
+++ menu_node.module	12 Aug 2009 19:15:44 -0000
@@ -273,15 +273,13 @@ function menu_node_edit_form_submit($for
  *   The menu link id.
  */
 function menu_node_save($nid, $mlid, $hook = 'update') {
-  $record = array('nid' => $nid, 'mlid' => $mlid);
   $new = menu_node_exists($nid, $mlid);
+  // We only save if the record does not exist, otherwise, call the update hook.
   if (empty($new)) {
+    $record = array('nid' => $nid, 'mlid' => $mlid);
     drupal_write_record('menu_node', $record);
     $hook = 'insert';
   }
-  else {
-    drupal_write_record('menu_node', $record, 'nid');
-  }
   _menu_node_invoke($nid, $mlid, $hook);
 }
 
