? .directory
? b.patch
? boost-720604.patch
? boost-785766.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.146
diff -u -p -r1.1.2.1.2.3.2.146 boost.admin.inc
--- boost.admin.inc	11 Aug 2010 19:09:43 -0000	1.1.2.1.2.3.2.146
+++ boost.admin.inc	24 Aug 2010 01:27:02 -0000
@@ -256,6 +256,50 @@ function boost_admin_boost_performance_p
     '#wysiwyg'       => FALSE,
   );
 
+  // Views intergration
+  if (module_exists('views')) {
+    $form['views'] = array(
+      '#type'          => 'fieldset',
+      '#title'         => t('Boost settings for views'),
+    );
+    $form['views']['boost_flush_views'] = array(
+      '#type'          => 'checkbox',
+      '#title'         => t('Clear all cached views pages associated with a node on update/delete'),
+      '#default_value' => BOOST_FLUSH_VIEWS,
+      '#description'   => t(''),
+    );
+    $form['views']['boost_flush_views_insert'] = array(
+      '#type'          => 'checkbox',
+      '#title'         => t('Clear all cached views pages associated with a node on insert'),
+      '#default_value' => BOOST_FLUSH_VIEWS_INSERT,
+      '#description'   => t('WARNING: This can be very slow, all views get run to find out where this node lives. Odds are it will not be slow, but if a node save takes a very long time with this enabled, you know why.'),
+    );
+    $form['views']['boost_flush_views_update'] = array(
+      '#type'          => 'checkbox',
+      '#title'         => t('Clear all cached views pages associated with a node on update'),
+      '#default_value' => BOOST_FLUSH_VIEWS_UPDATE,
+      '#description'   => t('WARNING: This can be very slow, all views get run to find out where this node lives. Odds are it will not be slow, but if a node save takes a very long time with this enabled, you know why.'),
+    );
+    $form['views']['boost_views_list_behavior'] = array(
+      '#type'          => 'radios',
+      '#title'         => t('New views behavior'),
+      '#default_value' => BOOST_VIEWS_LIST_BEHAVIOR,
+      '#options'       => array(
+        0 => t('Run code on cron to check if boost should use the view'),
+        1 => t('View is not tracked by boost until enabled'),
+      ),
+      '#description'   => t('This setting mainly effects new views.'),
+    );
+    $views = boost_views_get_valid_list();
+    $form['views']['boost_views_list_custom'] = array(
+      '#type' => 'checkboxes',
+      '#title' => t('Views to run when looking for content relationships'),
+      '#default_value' => $views,
+      '#options' => array_combine(array_keys($views), array_keys($views)),
+      '#description' => t('Leave these at the defaults unless you have a good reason to change it. Non-default settings should be at the top of this list.'),
+    );
+  }
+
   // Cache expiration settings
   $form['expiration'] = array(
     '#type'          => 'fieldset',
@@ -311,24 +355,6 @@ function boost_admin_boost_performance_p
       2 => t('Flushes Entire Menu Tree'),
     ),
   );
-  $form['expiration']['boost_flush_views'] = array(
-    '#type'          => 'checkbox',
-    '#title'         => t('Clear all cached views pages associated with a node on update/delete'),
-    '#default_value' => BOOST_FLUSH_VIEWS,
-    '#description'   => t(''),
-  );
-  $form['expiration']['boost_flush_views_insert'] = array(
-    '#type'          => 'checkbox',
-    '#title'         => t('Clear all cached views pages associated with a node on insert'),
-    '#default_value' => BOOST_FLUSH_VIEWS_INSERT,
-    '#description'   => t('WARNING: This can be very slow, all views get run to find out where this node lives. Odds are it will not be slow, but if a node save takes a very long time with this enabled, you know why.'),
-  );
-  $form['expiration']['boost_flush_views_update'] = array(
-    '#type'          => 'checkbox',
-    '#title'         => t('Clear all cached views pages associated with a node on update'),
-    '#default_value' => BOOST_FLUSH_VIEWS_UPDATE,
-    '#description'   => t('WARNING: This can be very slow, all views get run to find out where this node lives. Odds are it will not be slow, but if a node save takes a very long time with this enabled, you know why.'),
-  );
   $form['expiration']['boost_clear_cache_offline'] = array(
     '#type'          => 'checkbox',
     '#title'         => t('Clear Boosts cache when site goes offline'),
@@ -942,11 +968,43 @@ function boost_admin_boost_performance_p
 
   // Form validation
   $form['#validate'][] = 'boost_admin_boost_performance_page_validate';
+  $form['#submit'][] = 'boost_admin_boost_performance_page_submit';
   return system_settings_form($form);
 }
 
 /**
- * validate system_themes_form form submissions.
+ * submit boost_admin_boost_performance_page form submissions.
+ */
+function boost_admin_boost_performance_page_submit($form, &$form_state) {
+  $op = isset($form_state['values']['op']) ? $form_state['values']['op'] : '';
+  $key = 'boost_views_list_custom';
+
+  if ($op == t('Reset to defaults')) {
+    variable_del($key);
+  }
+  else {
+    $defaults = boost_views_generate_default_list();
+    $new = $form_state['values'][$key];
+    $disable = array_diff($defaults, $new);
+    $enable = array_diff($new, $defaults);
+    $values = $enable;
+    foreach ($disable as $hash => $value) {
+      $values[$hash] = $new[$hash];
+    }
+    unset($values['line-break']);
+
+    if ($values) {
+      variable_set($key, $values);
+    }
+    else {
+      variable_del($key);
+    }
+  }
+  unset($form_state['values'][$key]);
+}
+
+/**
+ * validate boost_admin_boost_performance_page form submissions.
  */
 function boost_admin_boost_performance_page_validate($form, &$form_state) {
   $boost_previously = variable_get('boost_enabled', '');
Index: boost.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/boost/boost.module,v
retrieving revision 1.3.2.2.2.5.2.364
diff -u -p -r1.3.2.2.2.5.2.364 boost.module
--- boost.module	11 Aug 2010 19:20:34 -0000	1.3.2.2.2.5.2.364
+++ boost.module	24 Aug 2010 01:27:04 -0000
@@ -36,6 +36,9 @@ define('BOOST_CACHE_JS',             var
 define('BOOST_CACHEABILITY_OPTION',  variable_get('boost_cacheability_option', 0));
 define('BOOST_CACHEABILITY_PAGES',   variable_get('boost_cacheability_pages', ''));
 
+// Views
+define('BOOST_VIEWS_LIST_BEHAVIOR',  variable_get('boost_views_list_behavior', 0));
+
 // Dir & File Structure
 define('BOOST_ROOT_CACHE_DIR',       variable_get('boost_root_cache_dir', 'cache'));
 define('BOOST_MULTISITE_SINGLE_DB',  variable_get('boost_multisite_single_db', TRUE));
@@ -220,29 +223,132 @@ function boost_node_get_basics($nid) {
  *  reference to the view being worked on
  */
 function boost_views_pre_render(&$view) {
-  if (!is_null($view) && $GLOBALS['_boost_cache_this'] && !BOOST_NO_DATABASE) {
-    foreach ($view->result as $item) {
-      if (is_numeric($item->nid)) {
-
-        $node = boost_node_get_basics($item->nid);
-        if (isset($node->type)) {
-          $info = array(
-            'child_page_callback' => 'node',
-            'child_page_type' => $node->type,
-            'child_page_id' => $item->nid,
-          );
-          if (BOOST_VERBOSE >= 9) {
-            $info['debug'] = array(
-              'view-name' => $view->name,
-              'view-display' => $view->current_display,
-              'node-path' => $node->path,
-            );
-          }
-          $GLOBALS['_boost_relationships'][] = $info;
+  // return if not a view, page not going to be cached, or if database turned off
+  if (is_null($view) || !$GLOBALS['_boost_cache_this'] || BOOST_NO_DATABASE) {
+    return;
+  }
+
+  // return if view doesn't belong in the set of views to search
+  $views = boost_views_get_valid_array();
+  $hash = $view->name . ' - ' . $view->current_display;
+  if (!array_key_exists($hash, $views)) {
+    return;
+  }
+
+  foreach ($view->result as $item) {
+    // skip if nid is not a number
+    if (!is_numeric($item->nid)) {
+      continue;
+    }
+
+    $node = boost_node_get_basics($item->nid);
+    // skip if node type is not set
+    if (!isset($node->type)) {
+      continue;
+    }
+    // set data
+    $info = array(
+      'child_page_callback' => 'node',
+      'child_page_type' => $node->type,
+      'child_page_id' => $item->nid,
+    );
+    if (BOOST_VERBOSE >= 9) {
+      $info['debug'] = array(
+        'view-name' => $view->name,
+        'view-display' => $view->current_display,
+        'node-path' => $node->path,
+      );
+    }
+    // send to global
+    $GLOBALS['_boost_relationships'][] = $info;
+  }
+}
+
+/**
+ * Genrate a list of views based off of defaults.
+ *
+ * Views that have a path, can be cached by boost & anonymous users can access
+ *
+ * @return array
+ *    (view_name . ' - ' . display_name . ' - /' . path => Enabled/Disabled)
+ */
+function boost_views_generate_default_list() {
+  $account = user_load(0);
+  $views = views_get_all_views();
+  $enabled = array();
+  $disabled = array();
+  foreach ($views as $view_name => $view) {
+    // disabled views get nothing.
+    if (!empty($view->disabled)) {
+      unset($views[$view_name]);
+      continue;
+    }
+
+    $view->init_display();
+    foreach ($view->display as $display_id => $display) {
+      // Make sure view has a path
+      // Anonymous users can access view
+      if (isset($display->display_options['path']) && $view->access($display_id, $account)) {
+        $path = $display->display_options['path'];
+        $hash = $view_name . ' - ' . $display_id . ' - /' . $path;
+        // Path is cacheable via boost & does not take arguments
+        if (boost_is_cacheable($path) && !stristr($path, '%')) {
+          $enabled[$hash] = $hash;
+        }
+        // Path is not cacheable via boost
+        else {
+          $disabled[$hash] = 0;
         }
       }
     }
   }
+  ksort($disabled);
+  natcasesort($enabled);
+  $checkboxes = array_merge(array('line-break' => 0), $disabled, $enabled);
+  return $checkboxes;
+}
+
+/**
+ * Genrate a list of valid views that boost will search for new content.
+ *
+ * @return array
+ */
+function boost_views_get_valid_list() {
+  // Load saved default values; if not saved, save it.
+  $defaults = variable_get('boost_views_list_default', FALSE);
+  if (!$defaults) {
+    $defaults = boost_views_generate_default_list();
+    variable_set('boost_views_list_default', $defaults);
+  }
+
+  // Load custom settings
+  $list = variable_get('boost_views_list_custom', array());
+  // Load defaults. http://php.net/operators.array
+  $list += $defaults;
+
+
+  return $list;
+}
+
+/**
+ * Genrate a list of valid views that boost will search for new content.
+ *
+ * @return array
+ */
+function boost_views_get_valid_array() {
+  $list = boost_views_get_valid_list();
+  $views = array();
+  foreach ($list as $hash => $enabled) {
+    if ($enabled) {
+      $info = explode(' - ', $hash);
+      $page_type = $info[0];
+      $page_id = $info[1];
+      $key = $page_type . ' - ' . $page_id;
+      $views[$key]['page_type'] = $page_type;
+      $views[$key]['page_id'] = $page_id;
+    }
+  }
+  return $views;
 }
 
 /**
@@ -521,6 +627,12 @@ function boost_cron() {
   }
   global $_boost;
 
+  // Check for new views on cron
+  if (BOOST_VIEWS_LIST_BEHAVIOR == 0) {
+    $defaults = boost_views_generate_default_list();
+    variable_set('boost_views_list_default', $defaults);
+  }
+
   $expire = TRUE;
   if (BOOST_CHECK_BEFORE_CRON_EXPIRE) {
     $expire = boost_has_site_changed(TRUE);
@@ -809,7 +921,7 @@ function _boost_view_insert($debug = FAL
   // Ensure we're in the correct working directory, since some web servers (e.g. Apache) mess this up here.
   chdir(dirname($_SERVER['SCRIPT_FILENAME']));
 
-  // Get all views that are not expired
+  // Get all views that are not expired in database
   if (BOOST_FLUSH_ALL_MULTISITE) {
     $result = db_query("SELECT page_id, page_type FROM {boost_cache} WHERE page_callback = 'view' AND expire > 0 AND expire <> 434966400 GROUP BY page_id, page_type");
   }
@@ -827,12 +939,8 @@ function _boost_view_insert($debug = FAL
     $views[$key]['page_type'] = $boost['page_type'];
     $views[$key]['page_id'] = $boost['page_id'];
   }
-  //   $results = db_query("SELECT id, name FROM {views_display} INNER JOIN {views_view} USING (vid) WHERE base_table = 'node'");
-  //   while ($row = db_fetch_array($results)) {
-  //     $key = $row['name'] . $row['id'];
-  //     $views[$key]['page_type'] = $row['name'];
-  //     $views[$key]['page_id'] = $row['id'];
-  //   }
+  // Get list of views that might contain the new content.
+  $views += boost_views_get_valid_array();
 
   // Loop through each node
   foreach ($_boost['new_nodes'] as $nid) {
