summaryrefslogtreecommitdiff
path: root/modules/search
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2010-04-06 16:28:25 +0000
committerDries Buytaert <dries@buytaert.net>2010-04-06 16:28:25 +0000
commitba59903d78f3e6074460ce81694403634d6419c6 (patch)
tree56e926d68c22de709d86128adc9f3017d0f944ef /modules/search
parentd5710f535850decf33a1f31600a3ea4f350682f2 (diff)
downloadbrdo-ba59903d78f3e6074460ce81694403634d6419c6.tar.gz
brdo-ba59903d78f3e6074460ce81694403634d6419c6.tar.bz2
- Patch #569536 by jhodgdon, douggreen, Berdir, grendzy, catch: search links cause many nodes to be indexed twice.
Diffstat (limited to 'modules/search')
-rw-r--r--modules/search/search.module5
-rw-r--r--modules/search/search.test49
2 files changed, 52 insertions, 2 deletions
diff --git a/modules/search/search.module b/modules/search/search.module
index c775478a1..376a98842 100644
--- a/modules/search/search.module
+++ b/modules/search/search.module
@@ -704,8 +704,9 @@ function search_index($sid, $type, $text) {
// 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,
diff --git a/modules/search/search.test b/modules/search/search.test
index 6a2103982..8ae018999 100644
--- a/modules/search/search.test
+++ b/modules/search/search.test
@@ -610,3 +610,52 @@ class SearchSimplifyTestCase extends DrupalWebTestCase {
$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', 'bypass node access')));
+ }
+
+ /**
+ * Verify the search settings form.
+ */
+ function testSearchSettingsPage() {
+ // Add a single piece of content and index it.
+ $node = $this->drupalCreateNode();
+ // Link the node to itself to test that it's only indexed once.
+ $langcode = LANGUAGE_NONE;
+ $body_key = "body[$langcode][0][value]";
+ $edit[$body_key] = l($node->title, 'node/' . $node->nid);
+ $this->drupalPost('node/' . $node->nid . '/edit', $edit, t('Save'));
+
+ 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.'));
+ }
+}
+