--- a/modules/node/node.module 2008-06-03 17:11:58.000000000 -0400
+++ b/modules/node/node.module 2008-05-15 15:36:24.000000000 -0400
@@ -2321,49 +2321,6 @@
}
/**
- * Implementation of hook_update_index().
- */
-function node_update_index() {
- global $last_change, $last_nid;
-
- register_shutdown_function('node_update_shutdown');
-
- $last = variable_get('node_cron_last', 0);
- $last_nid = variable_get('node_cron_last_nid', 0);
- $limit = (int)variable_get('search_cron_limit', 100);
-
- // Store the maximum possible comments per thread (used for ranking by reply count)
- variable_set('node_cron_comments_scale', 1.0 / max(1, db_result(db_query('SELECT MAX(comment_count) FROM {node_comment_statistics}'))));
- variable_set('node_cron_views_scale', 1.0 / max(1, db_result(db_query('SELECT MAX(totalcount) FROM {node_counter}'))));
-
- $result = db_query_range('SELECT GREATEST(IF(c.last_comment_timestamp IS NULL, 0, c.last_comment_timestamp), n.changed) as last_change, n.nid FROM {node} n LEFT JOIN {node_comment_statistics} c ON n.nid = c.nid WHERE n.status = 1 AND ((GREATEST(n.changed, c.last_comment_timestamp) = %d AND n.nid > %d) OR (n.changed > %d OR c.last_comment_timestamp > %d)) ORDER BY GREATEST(n.changed, c.last_comment_timestamp) ASC, n.nid ASC', $last, $last_nid, $last, $last, $last, 0, $limit);
-
- while ($node = db_fetch_object($result)) {
- $last_change = $node->last_change;
- $last_nid = $node->nid;
- $node = node_load($node->nid);
-
- // Build the node body.
- $node = node_build_content($node, FALSE, FALSE);
- $node->body = drupal_render($node->content);
-
- // Allow modules to modify the fully-built node.
- node_invoke_nodeapi($node, 'alter');
-
- $text = '
'. check_plain($node->title) .'
'. $node->body;
-
- // Fetch extra data normally not visible
- $extra = node_invoke_nodeapi($node, 'update index');
- foreach ($extra as $t) {
- $text .= $t;
- }
-
- // Update index
- search_index($node->nid, 'node', $text);
- }
-}
-
-/**
* Implementation of hook_form_alter().
*/
/*
--- a/modules/search/search.module 2008-06-03 17:11:58.000000000 -0400
+++ b/modules/search/search.module 2008-05-15 15:55:26.000000000 -0400
@@ -309,37 +309,14 @@
function search_cron() {
// We register a shutdown function to ensure that search_total is always up
// to date.
- register_shutdown_function('search_update_totals');
-
- // Update word index
foreach (module_list() as $module) {
- module_invoke($module, 'update_index');
+ if (module_hook($module, 'update_totals')) {
+ register_shutdown_function($module . '_update_totals');
}
}
-/**
- * This function is called on shutdown to ensure that search_total is always
- * up to date (even if cron times out or otherwise fails).
- */
-function search_update_totals() {
- // Update word IDF (Inverse Document Frequency) counts for new/changed words
- foreach (search_dirty() as $word => $dummy) {
- // Get total count
- $total = db_result(db_query("SELECT SUM(score) FROM {search_index} WHERE word = '%s'", $word));
- // Apply Zipf's law to equalize the probability distribution
- $total = log10(1 + 1/(max(1, $total)));
- db_query("UPDATE {search_total} SET count = %f WHERE word = '%s'", $total, $word);
- if (!db_affected_rows()) {
- db_query("INSERT INTO {search_total} (word, count) VALUES ('%s', %f)", $word, $total);
- }
- }
- // Find words that were deleted from search_index, but are still in
- // search_total. We use a LEFT JOIN between the two tables and keep only the
- // rows which fail to join.
- $result = db_query("SELECT t.word AS realword, i.word FROM {search_total} t LEFT JOIN {search_index} i ON t.word = i.word WHERE i.word IS NULL");
- while ($word = db_fetch_object($result)) {
- db_query("DELETE FROM {search_total} WHERE word = '%s'", $word->realword);
- }
+ // Update word index
+ module_invoke_all('update_index');
}
/**
--- a/sites/all/modules/coresearches/contentsearch.module 2008-06-03 16:43:17.000000000 -0400
+++ b/sites/all/modules/coresearches/contentsearch.module 2008-05-15 15:57:00.000000000 -0400
@@ -67,6 +67,32 @@
/**
+ * This function is called on shutdown to ensure that search_total is always
+ * up to date (even if cron times out or otherwise fails).
+ */
+function contentsearch_update_totals() {
+ // Update word IDF (Inverse Document Frequency) counts for new/changed words
+ foreach (search_dirty() as $word => $dummy) {
+ // Get total count
+ $total = db_result(db_query("SELECT SUM(score) FROM {search_index} WHERE word = '%s'", $word));
+ // Apply Zipf's law to equalize the probability distribution
+ $total = log10(1 + 1/(max(1, $total)));
+ db_query("UPDATE {search_total} SET count = %f WHERE word = '%s'", $total, $word);
+ if (!db_affected_rows()) {
+ db_query("INSERT INTO {search_total} (word, count) VALUES ('%s', %f)", $word, $total);
+ }
+ }
+ // Find words that were deleted from search_index, but are still in
+ // search_total. We use a LEFT JOIN between the two tables and keep only the
+ // rows which fail to join.
+ $result = db_query("SELECT t.word AS realword, i.word FROM {search_total} t LEFT JOIN {search_index} i ON t.word = i.word WHERE i.word IS NULL");
+ while ($word = db_fetch_object($result)) {
+ db_query("DELETE FROM {search_total} WHERE word = '%s'", $word->realword);
+ }
+}
+
+
+/**
* Implementation of hook_form_alter().
*/
function contentsearch_form_alter($form_id, &$form) {