summaryrefslogtreecommitdiff
path: root/modules/search.module
diff options
context:
space:
mode:
Diffstat (limited to 'modules/search.module')
-rw-r--r--modules/search.module11
1 files changed, 11 insertions, 0 deletions
diff --git a/modules/search.module b/modules/search.module
index e8294107d..42c658123 100644
--- a/modules/search.module
+++ b/modules/search.module
@@ -292,10 +292,21 @@ function search_dirty($word = null) {
* search_dirty).
*/
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');
}
+}
+
+/**
+ * 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