summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorSteven Wittens <steven@10.no-reply.drupal.org>2005-01-11 03:37:13 +0000
committerSteven Wittens <steven@10.no-reply.drupal.org>2005-01-11 03:37:13 +0000
commit854fa41fb31f38329402274249414b2be2a372d9 (patch)
treeb36f5bc2dca89e18fc272374e43c16b1b82e8578 /modules
parent59a2c464c7f870c0b0ff7802662bdbee20363986 (diff)
downloadbrdo-854fa41fb31f38329402274249414b2be2a372d9.tar.gz
brdo-854fa41fb31f38329402274249414b2be2a372d9.tar.bz2
- Fixing duplicate rows error during indexing
- Fixing broken "pagerank" detection
Diffstat (limited to 'modules')
-rw-r--r--modules/search.module8
-rw-r--r--modules/search/search.module8
2 files changed, 12 insertions, 4 deletions
diff --git a/modules/search.module b/modules/search.module
index dba620aa7..d8586d5db 100644
--- a/modules/search.module
+++ b/modules/search.module
@@ -181,7 +181,11 @@ function search_cron() {
$total = db_result(db_query("SELECT SUM(score) FROM {search_index} WHERE word = '%s'", $word));
db_query("UPDATE {search_total} SET count = %d WHERE word = '%s'", $total, $word);
if (!db_affected_rows()) {
- db_query("INSERT INTO {search_total} (word, count) VALUES ('%s', %d)", $word, $total);
+ // Note: affected rows does not count matching rows that already had the right value!
+ $exists = db_result(db_query("SELECT COUNT(*) FROM {search_total} WHERE word = '%s'", $word));
+ if (!$exists) {
+ db_query("INSERT INTO {search_total} (word, count) VALUES ('%s', %d)", $word, $total);
+ }
}
}
// Find words that were deleted from search_index, but are still in
@@ -331,7 +335,7 @@ function search_index($sid, $type, $text) {
// Check if link points to a node on this site
if (preg_match($node_regexp, $value, $match)) {
$path = drupal_get_normal_path($match[1]);
- if (preg_match('!(node|book)/(?:view/)?([0-9]+)!i', $path, $match)) {
+ if (preg_match('!(?:node|book)/(?:view/)?([0-9]+)!i', $path, $match)) {
$linknid = $match[1];
if ($linknid > 0) {
$link = true;
diff --git a/modules/search/search.module b/modules/search/search.module
index dba620aa7..d8586d5db 100644
--- a/modules/search/search.module
+++ b/modules/search/search.module
@@ -181,7 +181,11 @@ function search_cron() {
$total = db_result(db_query("SELECT SUM(score) FROM {search_index} WHERE word = '%s'", $word));
db_query("UPDATE {search_total} SET count = %d WHERE word = '%s'", $total, $word);
if (!db_affected_rows()) {
- db_query("INSERT INTO {search_total} (word, count) VALUES ('%s', %d)", $word, $total);
+ // Note: affected rows does not count matching rows that already had the right value!
+ $exists = db_result(db_query("SELECT COUNT(*) FROM {search_total} WHERE word = '%s'", $word));
+ if (!$exists) {
+ db_query("INSERT INTO {search_total} (word, count) VALUES ('%s', %d)", $word, $total);
+ }
}
}
// Find words that were deleted from search_index, but are still in
@@ -331,7 +335,7 @@ function search_index($sid, $type, $text) {
// Check if link points to a node on this site
if (preg_match($node_regexp, $value, $match)) {
$path = drupal_get_normal_path($match[1]);
- if (preg_match('!(node|book)/(?:view/)?([0-9]+)!i', $path, $match)) {
+ if (preg_match('!(?:node|book)/(?:view/)?([0-9]+)!i', $path, $match)) {
$linknid = $match[1];
if ($linknid > 0) {
$link = true;