? boost-453426.patch
Index: boost.admin.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/boost/boost.admin.inc,v
retrieving revision 1.1.2.1.2.3.2.40
diff -u -p -r1.1.2.1.2.3.2.40 boost.admin.inc
--- boost.admin.inc	22 Jul 2009 02:59:40 -0000	1.1.2.1.2.3.2.40
+++ boost.admin.inc	22 Jul 2009 09:58:22 -0000
@@ -528,7 +528,8 @@ function boost_clear_core_page_cache_sub
  */
 function boost_reset_database_submit () {
   if (boost_cache_clear_all()) {
-    db_query("DELETE FROM {boost_cache}");
+    db_query("TRUNCATE {boost_cache}");
+    db_query("TRUNCATE {boost_cache_settings}");
     drupal_set_message(t('Boost: Static page cache & database cleared.'));
   }
   else {
Index: boost.install
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/boost/boost.install,v
retrieving revision 1.2.2.1.2.3.2.20
diff -u -p -r1.2.2.1.2.3.2.20 boost.install
--- boost.install	6 Jul 2009 18:24:26 -0000	1.2.2.1.2.3.2.20
+++ boost.install	22 Jul 2009 09:58:23 -0000
@@ -124,12 +124,19 @@ function boost_schema() {
     'description' => t('List of the cached page'),
     'fields' => array(
       'filename' => array(
-        'description' => 'Path of the cached file relative to Drupal root.',
+        'description' => 'Path of the cached file relative to Drupal webroot.',
         'type' => 'varchar',
         'length' => 255,
         'not null' => TRUE,
         'default' => '',
       ),
+      'base_dir' => array(
+        'description' => 'Path of the cache root dir relative to Drupal webroot.',
+        'type' => 'varchar',
+        'length' => 128,
+        'not null' => TRUE,
+        'default' => '',
+      ),
       'expire' => array(
         'description' => t('UNIX timestamp for the expiration date of cached page.'),
         'type' => 'int',
@@ -164,10 +171,37 @@ function boost_schema() {
         'not null' => TRUE,
         'default' => ''
       ),
+      'page_id' => array(
+        'description' => 'The ID of the page.',
+        'type' => 'int',
+        'unsigned' => TRUE,
+        'not null' => TRUE,
+        'default' => 0,
+      ),
+      'timer' => array(
+        'type' => 'int',
+        'unsigned' => TRUE,
+        'not null' => TRUE,
+        'default' => 0,
+        'description' => 'Time in milliseconds that the page took to be generated.',
+      ),
+      'timer_average' => array(
+        'type' => 'float',
+        'not null' => TRUE,
+        'default' => 0,
+        'description' => 'Average time in milliseconds that the page took to be generated.',
+      ),
+
     ),
     'indexes' => array(
       'expire' => array('expire'),
       'push' => array('push'),
+      'base_dir' => array('base_dir'),
+      'page_id' => array('page_id'),
+      'timer' => array('timer'),
+      'timer_average' => array('timer_average'),
+      'page_callback' => array('page_callback'),
+      'page_arguments' => array('page_arguments'),
     ),
     'primary key' => array('filename'),
   );
@@ -180,6 +214,13 @@ function boost_schema() {
         'unsigned' => TRUE,
         'not null' => TRUE
       ),
+      'base_dir' => array(
+        'description' => 'Path of the cache root dir relative to Drupal webroot.',
+        'type' => 'varchar',
+        'length' => 128,
+        'not null' => TRUE,
+        'default' => '',
+      ),
       'page_callback' => array(
         'description' => 'The name of the function that renders the page.',
         'type' => 'varchar',
@@ -194,6 +235,13 @@ function boost_schema() {
         'not null' => TRUE,
         'default' => ''
       ),
+      'page_id' => array(
+        'description' => 'The ID of the page.',
+        'type' => 'int',
+        'unsigned' => TRUE,
+        'not null' => TRUE,
+        'default' => 0,
+      ),
       'lifetime' => array(
         'description' => t('Number of seconds this page should be considered fresh. Used to set the expiration column.'),
         'type' => 'int',
@@ -211,6 +259,8 @@ function boost_schema() {
     'indexes' => array(
       'page_callback' => array('page_callback'),
       'page_arguments' => array('page_arguments'),
+      'base_dir' => array('base_dir'),
+      'page_id' => array('page_id'),
     ),
     'primary key' => array('csid'),
   );
@@ -222,7 +272,105 @@ function boost_schema() {
  */
 function boost_update_6100() {
   // Create tables.
-  return drupal_install_schema('boost');
+  $schema['boost_cache'] = array(
+    'description' => t('List of the cached page'),
+    'fields' => array(
+      'filename' => array(
+        'description' => 'Path of the cached file relative to Drupal webroot.',
+        'type' => 'varchar',
+        'length' => 255,
+        'not null' => TRUE,
+        'default' => '',
+      ),
+      'expire' => array(
+        'description' => t('UNIX timestamp for the expiration date of cached page.'),
+        'type' => 'int',
+        'unsigned' => TRUE,
+        'not null' => TRUE,
+        'default' => 0,
+      ),
+      'lifetime' => array(
+        'description' => t('Number of seconds this page should be considered fresh. Used to set the expiration column.'),
+        'type' => 'int',
+        'not null' => TRUE,
+        'default' => -1,
+      ),
+      'push' => array(
+        'description' => 'A flag to indicate whether page should be crawled so it is fresh in the cache.',
+        'type' => 'int',
+        'size' => 'small',
+        'not null' => TRUE,
+        'default' => -1,
+      ),
+      'page_callback' => array(
+        'description' => 'The name of the function that renders the page.',
+        'type' => 'varchar',
+        'length' => 255,
+        'not null' => TRUE,
+        'default' => ''
+      ),
+      'page_arguments' => array(
+        'description' => 'The name of the content type.',
+        'type' => 'varchar',
+        'length' => 255,
+        'not null' => TRUE,
+        'default' => ''
+      ),
+    ),
+    'indexes' => array(
+      'expire' => array('expire'),
+      'push' => array('push'),
+    ),
+    'primary key' => array('filename'),
+  );
+  $schema['boost_cache_settings'] = array(
+    'description' => t('Boost cache settings'),
+    'fields' => array(
+      'csid' => array(
+        'description' => 'Primary Key: Unique cache settings ID.',
+        'type' => 'serial',
+        'unsigned' => TRUE,
+        'not null' => TRUE
+      ),
+      'page_callback' => array(
+        'description' => 'The name of the function that renders the page.',
+        'type' => 'varchar',
+        'length' => 255,
+        'not null' => TRUE,
+        'default' => ''
+      ),
+      'page_arguments' => array(
+        'description' => 'The name of the content type.',
+        'type' => 'varchar',
+        'length' => 255,
+        'not null' => TRUE,
+        'default' => ''
+      ),
+      'lifetime' => array(
+        'description' => t('Number of seconds this page should be considered fresh. Used to set the expiration column.'),
+        'type' => 'int',
+        'not null' => TRUE,
+        'default' => -1,
+      ),
+      'push' => array(
+        'description' => 'A flag to indicate whether page should be crawled so it is fresh in the cache.',
+        'type' => 'int',
+        'size' => 'small',
+        'not null' => TRUE,
+        'default' => -1,
+      ),
+    ),
+    'indexes' => array(
+      'page_callback' => array('page_callback'),
+      'page_arguments' => array('page_arguments'),
+    ),
+    'primary key' => array('csid'),
+  );
+
+  $ret = array();
+  db_create_table($ret, 'boost_cache', $schema['boost_cache']);
+  db_create_table($ret, 'boost_cache_settings', $schema['boost_cache_settings']);
+  return $ret;
 }
 
 /**
@@ -241,3 +389,70 @@ function boost_update_6102() {
   variable_del('boost_permissions');
   return array(array('success' => TRUE, 'query' => 'Old permissions variable deleted.'));
 }
+
+/**
+ * Update 6103 - Add new columns to tables
+ */
+function boost_update_6103() {
+  $ret = array();
+  // Add in base_dir column
+  db_add_field($ret, 'boost_cache', 'base_dir', array(
+        'description' => 'Path of the cache root dir relative to Drupal webroot.',
+        'type' => 'varchar',
+        'length' => 128,
+        'not null' => TRUE,
+        'default' => '',
+      ));
+  db_add_field($ret, 'boost_cache_settings', 'base_dir', array(
+        'description' => 'Path of the cache root dir relative to Drupal webroot.',
+        'type' => 'varchar',
+        'length' => 128,
+        'not null' => TRUE,
+        'default' => '',
+      ));
+  db_add_index($ret, 'boost_cache', 'base_dir', array('base_dir'));
+  db_add_index($ret, 'boost_cache_settings', 'base_dir', array('base_dir'));
+
+  // Add in page_id column
+  db_add_field($ret, 'boost_cache', 'page_id', array(
+        'description' => 'The ID of the page.',
+        'type' => 'int',
+        'unsigned' => TRUE,
+        'not null' => TRUE,
+        'default' => 0,
+      ));
+  db_add_field($ret, 'boost_cache_settings', 'page_id', array(
+        'description' => 'The ID of the page.',
+        'type' => 'int',
+        'unsigned' => TRUE,
+        'not null' => TRUE,
+        'default' => 0,
+      ));
+  db_add_index($ret, 'boost_cache', 'page_id', array('page_id'));
+  db_add_index($ret, 'boost_cache_settings', 'page_id', array('page_id'));
+
+  // Add in timer column
+  db_add_field($ret, 'boost_cache', 'timer', array(
+        'type' => 'int',
+        'unsigned' => TRUE,
+        'not null' => TRUE,
+        'default' => 0,
+        'description' => 'Time in milliseconds that the page took to be generated.',
+      ));
+  db_add_index($ret, 'boost_cache', 'timer', array('timer'));
+
+  // Add in timer_average column
+  db_add_field($ret, 'boost_cache', 'timer_average', array(
+        'type' => 'float',
+        'not null' => TRUE,
+        'default' => 0,
+        'description' => 'Average time in milliseconds that the page took to be generated.',
+      ));
+  db_add_index($ret, 'boost_cache', 'timer_average', array('timer_average'));
+
+  // Add indexes
+  db_add_index($ret, 'boost_cache', 'page_callback', array('page_callback'));
+  db_add_index($ret, 'boost_cache', 'page_arguments', array('page_arguments'));
+
+  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.78
diff -u -p -r1.3.2.2.2.5.2.78 boost.module
--- boost.module	22 Jul 2009 03:09:53 -0000	1.3.2.2.2.5.2.78
+++ boost.module	22 Jul 2009 09:58:23 -0000
@@ -101,8 +101,8 @@ function boost_init() {
     boost_set_cookie($user);
     if (BOOST_DISABLE_CLEAN_URL) {
       $GLOBALS['conf']['clean_url'] = 0;
-      db_query('TRUNCATE cache_filter');
-      db_query('TRUNCATE cache_menu');
+      db_query('TRUNCATE {cache_filter}');
+      db_query('TRUNCATE {cache_menu}');
       cache_clear_all('*', 'cache_menu');
       cache_clear_all('*', 'cache_filter');
     }
@@ -787,7 +787,7 @@ function boost_cache_expire_all() {
  * Resets all entries in database.
  */
 function boost_cache_clear_all_db() {
-  db_query("UPDATE {boost_cache} SET expire = %d", 0);
+  db_query("UPDATE {boost_cache} SET expire = %d WHERE base_dir = '%s'", 0, BOOST_FILE_PATH);
 }
 
 /**
@@ -1008,6 +1008,8 @@ function boost_cache_set($path, $data = 
 function boost_db_prep($filename, $lifetime = -1, $push = -1) {
   $router_item = _boost_get_menu_router();
   $expire = BOOST_CACHE_LIFETIME + BOOST_TIME;
+  $timer = timer_read('page');
+  $timer_average = $timer;
 
   $boost_settings_db = boost_get_settings_db($router_item);
   $boost_db = boost_get_db($filename);
@@ -1016,6 +1018,7 @@ function boost_db_prep($filename, $lifet
     $expire = $boost_db['lifetime'] != -1 ? $boost_db['lifetime'] + BOOST_TIME : $expire;
     $lifetime = $boost_db['lifetime'];
     $push = $boost_db['push'];
+    $timer_average = ($boost_db['timer_average'] + $timer)/2;
   }
   //get data from settings table, if this page has not been put into the cache.
   elseif ($boost_settings_db) {
@@ -1024,7 +1027,7 @@ function boost_db_prep($filename, $lifet
     $push = $boost_settings_db['push'];
   }
 
-  boost_put_db($filename, $expire, $lifetime, $push, $router_item);
+  boost_put_db($filename, $expire, $lifetime, $push, $router_item, $timer, $timer_average);
 }
 
 /**
@@ -1039,12 +1042,12 @@ function boost_db_prep($filename, $lifet
  * @param $push
  *   Pre-cache this file
  * @param $router_item
- *   Array containing page_callback & page_arguments.
+ *   Array containing page_callback, page_arguments & page_id.
  */
-function boost_put_db($filename, $expire, $lifetime, $push, $router_item) {
-  db_query("UPDATE {boost_cache} SET expire = %d, lifetime = %d, push = %d, page_callback = '%s', page_arguments = '%s' WHERE filename = '%s'", $expire, $lifetime, $push, $router_item['page_callback'], $router_item['page_arguments'], $filename);
+function boost_put_db($filename, $expire, $lifetime, $push, $router_item, $timer, $timer_average) {
+  db_query("UPDATE {boost_cache} SET expire = %d, lifetime = %d, push = %d, page_callback = '%s', page_arguments = '%s', timer = %d, timer_average = %d, base_dir = '%s', page_id = '%s' WHERE filename = '%s'", $expire, $lifetime, $push, $router_item['page_callback'], $router_item['page_arguments'], $timer, $timer_average, BOOST_FILE_PATH, $router_item['page_id'], $filename);
   if (!db_affected_rows()) {
-    @db_query("INSERT INTO {boost_cache} (filename, expire, lifetime, push, page_callback, page_arguments) VALUES ('%s', %d, %d, %d, '%s', '%s')", $filename, $expire, $lifetime, $push, $router_item['page_callback'], $router_item['page_arguments']);
+    @db_query("INSERT INTO {boost_cache} (filename, expire, lifetime, push, page_callback, page_arguments, timer, timer_average, base_dir, page_id) VALUES ('%s', %d, %d, %d, '%s', '%s', %d, %d, '%s', '%s')", $filename, $expire, $lifetime, $push, $router_item['page_callback'], $router_item['page_arguments'], $timer, $timer_average, BOOST_FILE_PATH, $router_item['page_id']);
   }
 }
 
@@ -1084,7 +1087,7 @@ function boost_set_db_page_settings($lif
  *   Filename to be looked up in the database
  */
 function boost_get_db($filename) {
-  return db_fetch_array(db_query_range("SELECT expire, lifetime, push FROM {boost_cache} WHERE filename = '%s'", $filename, 0, 1));
+  return db_fetch_array(db_query_range("SELECT * FROM {boost_cache} WHERE filename = '%s'", $filename, 0, 1));
 }
 
 /**
@@ -1529,21 +1532,23 @@ function _boost_get_menu_router() {
   list($ancestors, $placeholders) = menu_get_ancestors($parts);
   $router_item = db_fetch_array(db_query_range('SELECT page_callback, page_arguments FROM {menu_router} WHERE path IN ('. implode (',', $placeholders) .') ORDER BY fit DESC', $ancestors, 0, 1));
   $router_item['page_arguments'] = unserialize($router_item['page_arguments']);
-  //handle nodes
+  // Handle nodes
   if (arg(0) == 'node' && is_numeric(arg(1))) {
     $node = node_load(arg(1));
     $router_item['page_arguments'] = $node->type;
     $router_item['page_callback'] = 'node';
+    $router_item['page_id'] = arg(1);
 
   }
-  //handle taxonomy
+  // Handle taxonomy
   elseif (arg(0) == 'taxonomy' && is_numeric(arg(2))) {
     $term = taxonomy_get_term(arg(2));
     $vocab = taxonomy_vocabulary_load($term->vid);
     $router_item['page_arguments'] = $vocab->name;
     $router_item['page_callback'] = 'taxonomy';
+    $router_item['page_id'] = arg(2);
   }
-  //try to handle everything else
+  // Try to handle everything else
   elseif (is_array($router_item['page_arguments'])) {
     foreach ($router_item['page_arguments'] as $string) {
       if (is_string($string)) {
@@ -1552,10 +1557,23 @@ function _boost_get_menu_router() {
       }
     }
   }
-  //set empty if page_arguments is an empty object.
+  // Set empty if page_arguments is an empty object.
   if (empty($router_item['page_arguments'])) {
     $router_item['page_arguments'] = '';
   }
+
+  // Handle Views
+  if ($router_item['page_callback'] == 'views_page') {
+    $vid = db_fetch_array(db_query_range("SELECT vid FROM {views_view} WHERE name = '%s'", $router_item['page_arguments'], 0, 1));
+    $router_item['page_id'] = $vid['vid'];
+  }
+
+  // Handle Panels
+  if ($router_item['page_callback'] == 'delegator_page_execute') {
+    $pid = db_fetch_array(db_query_range("SELECT pid FROM {delegator_pages} WHERE name = '%s'", $router_item['page_arguments'], 0, 1));
+    $router_item['page_id'] = $pid['pid'];
+  }
+
   return $router_item;
 }
 
