--- modules/menu/menu.admin.inc	2010-10-20 09:40:59.000000000 +0200
+++ modules/menu/menu.admin.inc	2011-01-21 16:41:08.000000000 +0100
@@ -385,6 +385,19 @@ function menu_edit_item_validate($form, 
   if (!trim($item['link_path']) || !drupal_valid_path($item['link_path'], TRUE)) {
     form_set_error('link_path', t("The path '@link_path' is either invalid or you do not have access to it.", array('@link_path' => $item['link_path'])));
   }
+  elseif (preg_match('/^node\/(\d+)/', trim($item['link_path']), $matches)) {
+    $type = db_query("SELECT type FROM {node} WHERE nid = :nid", array(':nid' => $matches[1]))->fetchField();
+    if ($type) {
+      $type_menus = variable_get('menu_options_'. $type, array('main-menu' => 'main-menu'));
+      list($menu_name, $plid) = explode(':', $item['parent']);
+      if (!in_array($menu_name, $type_menus)) {
+        form_set_error('parent', t("The %menu_title menu cannot contain links to the path '@link_path'.", array(
+          '%menu_title' => substr($form['parent']['#options'][$menu_name .':0'], 1, -1),
+          '@link_path' => $item['link_path'],
+        )));
+      }
+    }
+  }
 }
 
 /**
--- modules/menu/menu.test	2010-10-13 15:43:21.000000000 +0200
+++ modules/menu/menu.test	2011-01-21 19:23:10.000000000 +0100
@@ -170,6 +170,7 @@ class MenuTestCase extends DrupalWebTest
     $this->assertResponse(200);
     $this->assertText(t('The block settings have been updated.'), t('Custom menu block was enabled'));
 
+    menu_cache_clear_all();
     return menu_load($menu_name);
   }
 
@@ -204,6 +205,10 @@ class MenuTestCase extends DrupalWebTest
     $node4 = $this->drupalCreateNode(array('type' => 'article'));
     $node5 = $this->drupalCreateNode(array('type' => 'article'));
 
+    // Set menu as available for article content type.
+    $menu_options = array_unique(array_merge(variable_get('menu_options_article', array('main-menu')), array($menu_name)));
+    variable_set('menu_options_article', $menu_options);
+
     // Add menu links.
     $item1 = $this->addMenuLink(0, 'node/' . $node1->nid, $menu_name);
     $item2 = $this->addMenuLink($item1['mlid'], 'node/' . $node2->nid, $menu_name);
@@ -254,6 +259,14 @@ class MenuTestCase extends DrupalWebTest
     // Save menu links for later tests.
     $this->items[] = $item1;
     $this->items[] = $item2;
+
+    // Set menu as unavailable for article content type.
+    $menu_options = array_values(array_diff($menu_options, array($menu_name)));
+    variable_set('menu_options_article', $menu_options);
+
+    // Attempt to add a menu link.
+    $this->addMenuLinkToUnavailableMenu(0, 'node/'. $node1->nid, $menu_name);
+    $this->addMenuLinkToUnavailableMenu($item1['mlid'], 'node/'. $node1->nid, $menu_name);
   }
 
   /**
@@ -314,6 +327,27 @@ class MenuTestCase extends DrupalWebTest
   }
 
   /**
+   * Attempt to add a menu link to a menu unavailable for the linked content type, using the menu module UI.
+   *
+   * @param integer $plid Parent menu link id.
+   * @param string $link Link path.
+   * @param string $menu_name Unavailable menu name.
+   */
+  function addMenuLinkToUnavailableMenu($plid = 0, $link = '<front>', $menu_name = 'navigation') {
+    $menus = menu_get_menus();
+    $edit = array(
+      'link_path' => $link,
+      'link_title' => 'title',
+      'parent' =>  $menu_name .':'. $plid,
+    );
+    $this->drupalPost("admin/structure/menu/manage/$menu_name/add", $edit, t('Save'));
+    $this->assertRaw(t("The %menu_title menu cannot contain links to the path '@link_path'.", array(
+      '%menu_title' => $menus[$menu_name],
+      '@link_path' => $link,
+    )), 'Menu link was not created');
+  }
+
+  /**
    * Attempt to add menu link with invalid path or no access permission.
    *
    * @param string $menu_name Menu name.
