diff options
author | Steven Wittens <steven@10.no-reply.drupal.org> | 2006-04-03 22:56:10 +0000 |
---|---|---|
committer | Steven Wittens <steven@10.no-reply.drupal.org> | 2006-04-03 22:56:10 +0000 |
commit | 826396a4efa4dfb557effaa4075ce6d556a4d6b9 (patch) | |
tree | 40ae69397ed60387efa9d073e6adeeb4fbedc15a /modules | |
parent | ee207b4869252c4eb318d19f2018ff1491c541bc (diff) | |
download | brdo-826396a4efa4dfb557effaa4075ce6d556a4d6b9.tar.gz brdo-826396a4efa4dfb557effaa4075ce6d556a4d6b9.tar.bz2 |
Fix search indexer link tracking after removal of base-tag.
Diffstat (limited to 'modules')
-rw-r--r-- | modules/search.module | 9 | ||||
-rw-r--r-- | modules/search/search.module | 9 |
2 files changed, 10 insertions, 8 deletions
diff --git a/modules/search.module b/modules/search.module index d7129c1e7..3d3bc9124 100644 --- a/modules/search.module +++ b/modules/search.module @@ -258,14 +258,15 @@ function search_wipe_confirm_submit($form_id, &$form) { * @param $type * (optional) The type of item to wipe. */ -function search_wipe($sid = NULL, $type = NULL) { +function search_wipe($sid = NULL, $type = NULL, $reindex = FALSE) { if ($type == NULL && $sid == NULL) { module_invoke_all('search', 'reset'); } else { db_query("DELETE FROM {search_dataset} WHERE sid = %d AND type = '%s'", $sid, $type); - db_query("DELETE FROM {search_index} WHERE sid = %d AND type = '%s'", $sid, $type); db_query("DELETE FROM {search_index} WHERE fromsid = %d AND fromtype = '%s'", $sid, $type); + // When re-indexing, keep link references + db_query("DELETE FROM {search_index} WHERE sid = %d AND type = '%s'". ($reindex ? " AND fromsid = 0" ; ''), $sid, $type); } } @@ -449,7 +450,7 @@ function search_index($sid, $type, $text) { // Link matching global $base_url; - $node_regexp = '@href=[\'"]?(?:'. preg_quote($base_url, '@') .'/)?(?:\?q=)?/?((?![a-z]+:)[^\'">]+)[\'">]@i'; + $node_regexp = '@href=[\'"]?(?:'. preg_quote($base_url, '@') .'/|'. preg_quote(base_path(), '@') .')(?:\?q=)?/?((?![a-z]+:)[^\'">]+)[\'">]@i'; // Multipliers for scores of words inside certain HTML tags. // Note: 'a' must be included for link ranking to work. @@ -586,7 +587,7 @@ function search_index($sid, $type, $text) { $tag = !$tag; } - search_wipe($sid, $type); + search_wipe($sid, $type, TRUE); // Insert cleaned up data into dataset db_query("INSERT INTO {search_dataset} (sid, type, data) VALUES (%d, '%s', '%s')", $sid, $type, $accum); diff --git a/modules/search/search.module b/modules/search/search.module index d7129c1e7..3d3bc9124 100644 --- a/modules/search/search.module +++ b/modules/search/search.module @@ -258,14 +258,15 @@ function search_wipe_confirm_submit($form_id, &$form) { * @param $type * (optional) The type of item to wipe. */ -function search_wipe($sid = NULL, $type = NULL) { +function search_wipe($sid = NULL, $type = NULL, $reindex = FALSE) { if ($type == NULL && $sid == NULL) { module_invoke_all('search', 'reset'); } else { db_query("DELETE FROM {search_dataset} WHERE sid = %d AND type = '%s'", $sid, $type); - db_query("DELETE FROM {search_index} WHERE sid = %d AND type = '%s'", $sid, $type); db_query("DELETE FROM {search_index} WHERE fromsid = %d AND fromtype = '%s'", $sid, $type); + // When re-indexing, keep link references + db_query("DELETE FROM {search_index} WHERE sid = %d AND type = '%s'". ($reindex ? " AND fromsid = 0" ; ''), $sid, $type); } } @@ -449,7 +450,7 @@ function search_index($sid, $type, $text) { // Link matching global $base_url; - $node_regexp = '@href=[\'"]?(?:'. preg_quote($base_url, '@') .'/)?(?:\?q=)?/?((?![a-z]+:)[^\'">]+)[\'">]@i'; + $node_regexp = '@href=[\'"]?(?:'. preg_quote($base_url, '@') .'/|'. preg_quote(base_path(), '@') .')(?:\?q=)?/?((?![a-z]+:)[^\'">]+)[\'">]@i'; // Multipliers for scores of words inside certain HTML tags. // Note: 'a' must be included for link ranking to work. @@ -586,7 +587,7 @@ function search_index($sid, $type, $text) { $tag = !$tag; } - search_wipe($sid, $type); + search_wipe($sid, $type, TRUE); // Insert cleaned up data into dataset db_query("INSERT INTO {search_dataset} (sid, type, data) VALUES (%d, '%s', '%s')", $sid, $type, $accum); |