? boost-620636.patch
Index: boost.install
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/boost/boost.install,v
retrieving revision 1.2.2.1.2.3.2.68
diff -u -p -r1.2.2.1.2.3.2.68 boost.install
--- boost.install	1 Nov 2009 04:55:41 -0000	1.2.2.1.2.3.2.68
+++ boost.install	2 Nov 2009 08:19:23 -0000
@@ -369,6 +369,16 @@ if (!function_exists("scandir")) {
 }
 
 /**
+ * Attempts to set the PHP maximum execution time.
+ * See http://api.drupal.org/api/function/drupal_set_time_limit/7
+ */
+function _boost_install_set_time_limit($time_limit) {
+  if (function_exists('set_time_limit')) {
+    @set_time_limit($time_limit);
+  }
+}
+
+/**
  * Implementation of hook_schema().
  */
 function boost_schema() {
@@ -1296,11 +1306,26 @@ function boost_update_6120() {
 }
 
 /**
- * Attempts to set the PHP maximum execution time.
- * See http://api.drupal.org/api/function/drupal_set_time_limit/7
+ * Update 6121 - Add indexes to database for boost_has_site_changed() function.
  */
-function _boost_install_set_time_limit($time_limit) {
-  if (function_exists('set_time_limit')) {
-    @set_time_limit($time_limit);
-  }
+function boost_update_6121() {
+  $GLOBALS['_boost_max_execution_time'] =  ini_get('max_execution_time');
+  ini_set('max_execution_time', 10800); //3 Hours
+  _boost_install_set_time_limit(0);
+
+  // Make sure we have boost.module file loaded
+  drupal_load('module', 'boost');
+
+  $ret = array();
+  _boost_index_exists($ret, 'node_revisions', 'timestamp');
+  _boost_index_exists($ret, 'files', 'timestamp');
+  _boost_index_exists($ret, 'comments', 'timestamp');
+  _boost_index_exists($ret, 'node', 'changed');
+  _boost_index_exists($ret, 'files', 'timestamp');
+  _boost_index_exists($ret, 'node_comment_statistics', 'last_comment_timestamp');
+  _boost_index_exists($ret, 'votingapi_vote', 'timestamp');
+
+  _boost_install_set_time_limit(0);
+  ini_set('max_execution_time', $GLOBALS['_boost_max_execution_time']);
+  return $ret;
 }
Index: boost.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/boost/boost.module,v
retrieving revision 1.3.2.2.2.5.2.219
diff -u -p -r1.3.2.2.2.5.2.219 boost.module
--- boost.module	1 Nov 2009 04:56:48 -0000	1.3.2.2.2.5.2.219
+++ boost.module	2 Nov 2009 08:19:25 -0000
@@ -2224,14 +2224,29 @@ function boost_get_settings_db($router_i
  */
 function boost_has_site_changed($set_max = FALSE) {
 
+  // Make sure database has been indexed.
+  if (boost_drupal_get_installed_schema_version('boost') <= 6120) {
+    return FALSE;
+  }
+
+  // Index any new tables
+  $ret = array();
+  _boost_index_exists($ret, 'node_revisions', 'timestamp');
+  _boost_index_exists($ret, 'files', 'timestamp');
+  _boost_index_exists($ret, 'comments', 'timestamp');
+  _boost_index_exists($ret, 'node', 'changed');
+  _boost_index_exists($ret, 'files', 'timestamp');
+  _boost_index_exists($ret, 'node_comment_statistics', 'last_comment_timestamp');
+  _boost_index_exists($ret, 'votingapi_vote', 'timestamp');
+
   // Get timestamps from the database
   $node_revisions = boost_get_time('node_revisions', 'timestamp');
   //$history = boost_get_time('history', 'timestamp');
   $files = boost_get_time('files', 'timestamp');
   $comments = boost_get_time('comments', 'timestamp');
+  $voteapi_vote = boost_get_time('votingapi_vote', 'timestamp');
   $node = boost_get_time('node', 'changed');
   $last_comment_timestamp = boost_get_time('node_comment_statistics', 'last_comment_timestamp');
-  $voteapi_vote = boost_get_time('votingapi_vote', 'timestamp');
 
   $max = max($node_revisions, $files, $comments, $node, $last_comment_timestamp, $voteapi_vote);
   if ($max != BOOST_MAX_TIMESTAMP) {
@@ -2246,6 +2261,39 @@ function boost_has_site_changed($set_max
 }
 
 /**
+ * Returns the currently installed schema version for a module.
+ *
+ * @see drupal_get_installed_schema_version()
+ *
+ * @param $module
+ *   A module name.
+ * @param $reset
+ *   Set to TRUE after modifying the system table.
+ * @param $array
+ *   Set to TRUE if you want to get information about all modules in the
+ *   system.
+ * @return
+ *   The currently installed schema version.
+ */
+function boost_drupal_get_installed_schema_version($module, $reset = FALSE, $array = FALSE) {
+  static $versions = array();
+
+  if ($reset) {
+    $versions = array();
+  }
+
+  if (!$versions) {
+    $versions = array();
+    $result = db_query("SELECT name, schema_version FROM {system} WHERE type = '%s'", 'module');
+    while ($row = db_fetch_object($result)) {
+      $versions[$row->name] = $row->schema_version;
+    }
+  }
+
+  return $array ? $versions : $versions[$module];
+}
+
+/**
  * Checks various timestamps in the database.
  *
  * @param $table
@@ -2601,6 +2649,33 @@ function boost_glue_url($parsed) {
 //////////////////////////////////////////////////////////////////////////////
 // Boost API internals
 
+
+/**
+ * Add an index if it doesn't exist
+ *
+ * @param $ret
+ *   Array to which query results will be added.
+ * @param $table
+ *   The table to be altered.
+ * @param $name
+ *   The name of the index.
+ * @param $fields
+ *   An array of field names.
+ */
+function _boost_index_exists(&$ret, $table, $index) {
+  if (db_table_exists($table)) {
+    $result = db_query('SHOW INDEX FROM {%s}', $table);
+    while ($name = db_fetch_array($result)) {
+      if ($name['Key_name'] == $index) {
+        return TRUE;
+      }
+    }
+    // Index doesn't exists create it
+    db_add_index($ret, $table, $index, array($index));
+  }
+  return FALSE;
+}
+
 /**
  * Change a file extension in the database.
  *
