Index: modules/search/search.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/search/search.module,v
retrieving revision 1.338
diff -u -r1.338 search.module
--- modules/search/search.module	17 Feb 2010 22:44:52 -0000	1.338
+++ modules/search/search.module	25 Feb 2010 16:33:01 -0000
@@ -704,8 +704,9 @@
       // Unset the link to mark it as processed.
       unset($links[$nid]);
     }
-    else {
-      // Insert the existing link and mark the node for reindexing.
+    elseif ($sid != $nid || $type != 'node') {
+      // Insert the existing link and mark the node for reindexing, but don't
+      // reindex if this is a link in a node pointing to itself.
       db_insert('search_node_links')
         ->fields(array(
           'caption' => $caption,
Index: modules/search/search.test
===================================================================
RCS file: /cvs/drupal/drupal/modules/search/search.test,v
retrieving revision 1.52
diff -u -r1.52 search.test
--- modules/search/search.test	7 Feb 2010 17:29:09 -0000	1.52
+++ modules/search/search.test	25 Feb 2010 16:33:01 -0000
@@ -599,3 +599,46 @@
     $this->assertIdentical(' ', search_simplify($string), t('Search simplify works for ASCII control characters.'));
   }
 }
+
+
+/**
+ * Test config page.
+ */
+class SearchConfigSettingsForm extends DrupalWebTestCase {
+  public static function getInfo() {
+    return array(
+      'name' => 'Config settings form',
+      'description' => 'Verify the search config settings form.',
+      'group' => 'Search',
+    );
+  }
+
+  function setUp() {
+    parent::setUp('search');
+
+    // Login as a user that can create and search content.
+    $this->drupalLogin($this->drupalCreateUser(array('search content', 'administer search', 'administer nodes')));
+  }
+
+  /**
+   * Verify the search settings form.
+   */
+  function testSearchSettingsPage() {
+    // Add a single piece of content and index it.
+    $node = $this->drupalCreateNode();
+    node_update_index();
+    search_update_totals();
+
+    // Test that the settings form displays the correct count of items left to index.
+    $this->drupalGet('admin/config/search/settings');
+    $this->assertText(t('There are @count items left to index.', array('@count' => 0)));
+
+    // Test the re-index button.
+    $this->drupalPost('admin/config/search/settings', array(), t('Re-index site'));
+    $this->assertText(t('Are you sure you want to re-index the site'));
+    $this->drupalPost('admin/config/search/settings/reindex', array(), t('Re-index site'));
+    $this->assertText(t('The index will be rebuilt'));
+    $this->drupalGet('admin/config/search/settings');
+    $this->assertText(t('There is 1 item left to index.'));
+  }
+}
