Index: modules/shortcut/shortcut.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/shortcut/shortcut.module,v
retrieving revision 1.24
diff -u -p -r1.24 shortcut.module
--- modules/shortcut/shortcut.module	6 Mar 2010 06:33:14 -0000	1.24
+++ modules/shortcut/shortcut.module	14 May 2010 17:22:33 -0000
@@ -354,13 +354,24 @@ function shortcut_set_save(&$shortcut_se
   }
   // If links were provided for the set, save them.
   if (isset($shortcut_set->links)) {
+    // We will store all menu link IDs in order to be able to remove any other
+    // links that should not be in the set.
+    $mlids = array();
     foreach ($shortcut_set->links as &$link) {
       // Do not specifically associate these links with the shortcut module,
       // since other modules may make them editable via the menu system.
       // However, we do need to specify the correct menu name.
       $link['menu_name'] = $shortcut_set->set_name;
       $link['plid'] = 0;
-      menu_link_save($link);
+      $mlids[] = menu_link_save($link);
+    }
+    // Make sure that the links provided in the set are the only ones actually
+    // in the set.
+    $links = menu_load_links($shortcut_set->set_name);
+    foreach ($links as &$link) {
+      if (in_array($link['mlid'], $mlids)) {
+        menu_link_delete($link['mlid']);
+      }
     }
     // Make sure that we have a return value, since if the links were updated
     // but the shortcut set was not, the call to drupal_write_record() above
Index: modules/shortcut/shortcut.test
===================================================================
RCS file: /cvs/drupal/drupal/modules/shortcut/shortcut.test,v
retrieving revision 1.1
diff -u -p -r1.1 shortcut.test
--- modules/shortcut/shortcut.test	6 Mar 2010 06:33:14 -0000	1.1
+++ modules/shortcut/shortcut.test	14 May 2010 17:22:33 -0000
@@ -251,6 +251,16 @@ class ShortcutSetsTestCase extends Short
 
     $new_mlids = $this->getShortcutInformation($saved_set, 'mlid');
     $this->assertTrue(count(array_intersect($old_mlids, $new_mlids)) == count($old_mlids), 'shortcut_set_save() did not inadvertently change existing mlids.');
+
+    // Make sure that shortcut_set_save() removes links that do not exist in
+    // the set that was passed to it.
+    $old_mlids = $new_mlids;
+    $link = array_pop($saved_set->links);
+    $deleted_mlid = $link['mlid'];
+    shortcut_set_save($saved_set);
+    $saved_set = shortcut_set_load($saved_set->set_name);
+    $new_mlids = $this->getShortcutInformation($saved_set, 'mlid');
+    $this->assertFalse(array_search($deleted_mlid, $new_mlids), 'shortcut_set_save() removed items that were not provided in the set from the database.');
   }
 
   /**
