Index: content_views.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/cck/content_views.inc,v
retrieving revision 1.2.2.5
diff -u -r1.2.2.5 content_views.inc
--- content_views.inc	5 Jan 2007 11:57:46 -0000	1.2.2.5
+++ content_views.inc	19 Jan 2007 20:04:07 -0000
@@ -66,6 +66,9 @@
         $table['sorts'][$main_column['column']] = array(
           'name' => $field_types[$field['type']]['label'] .': '. $field['widget']['label'] .' ('. $field['field_name'] .')',
           'field' => $main_column['column'],
+          'content_db_info' => $db_info,
+          'content_field' => $field,
+          'content_field_module' => $module,
         );
       }
 
@@ -82,6 +85,9 @@
           $init = array(
             'name' => $name,
             'field' => $main_column['column'],
+            'content_db_info' => $db_info,
+            'content_field' => $field,
+            'content_field_module' => $module,
           );
           $table['filters'][$main_column['column'] .'_'. $key] = array_merge($filter, $init);
         }
@@ -250,30 +256,53 @@
 }
 
 /**
- * Rebuild the cached queries for the views using a given field
- * used when a field changes its 'multiple' status
- * plus helper function for updates
+ * Rebuild the cached queries for the views using a given field.
+ * Called when a field changes its 'multiple' status.
+ * Can also be useful for updates.
  *
  * @param unknown_type $update_fields
  */
+
 function _content_views_rebuild_views($update_fields) {
+  $updated_views = array();
   views_load_cache();
-  $tables = _views_get_tables();
+  $tables = _views_get_tables(true);
   $result = db_query("SELECT name, query FROM {view_view} ORDER BY name");
+  // TODO : do we have to do that for default views as well ?
   while ($row = db_fetch_array($result)) {
     // if a query has been stored for the view
     if (!empty($row['query'])) {
       $view = views_get_view($row['name']);
-      // TODO : check for arguments / sorts / filters as well ?
+      $view_content_fields = array();
+
       foreach ($view->field as $field) {
-        // if the view contains one of the fields that require updating
-        $field_info = $tables[$field['tablename']]['fields'][$field['field']];
-        if (isset($field_info['content_field']) && in_array($field_info['content_field']['field_name'], $update_fields)) {
-          // re-save the view (forces the query to be updated)
-          _views_save_view($view);
-          break;
+        $info = $tables['fields']['base'][$field['fullname']];
+        if (isset($info['content_field'])) {
+          $view_content_fields[] = $info['content_field']['field_name'];
+        }
+      }
+
+      foreach ($view->filter as $filter) {
+        $info = $tables['filters']['base'][$filter['field']];
+        if (isset($info['content_field'])) {
+          $view_content_fields[] = $info['content_field']['field_name'];
         }
       }
+
+      foreach ($view->sort as $sort) {
+        $info = $tables['sorts']['base'][$sort['field']];
+        if (isset($info['content_field'])) {
+          $view_content_fields[] = $info['content_field']['field_name'];
+        }
+      }
+
+      // no need to check arguments : a view with arguments is not cacheable
+
+      if (count(array_intersect($view_content_fields, $update_fields))) {
+        _views_save_view($view);
+        $updated_views[] = $view->name;
+      }
     }
   }
+  return $updated_views;
 }
Index: content.install
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/cck/content.install,v
retrieving revision 1.14.2.8
diff -u -r1.14.2.8 content.install
--- content.install	18 Jan 2007 17:50:50 -0000	1.14.2.8
+++ content.install	19 Jan 2007 20:02:17 -0000
@@ -308,3 +308,67 @@
 
   return $ret;
 }
+
+/**
+ *  Rename 'per content type' data tables to avoid collision with core node_* tables
+ */
+function content_update_1003() {
+  $ret = array();
+
+  // We check the update has not already been done in 4.7 migration path
+  if (!db_table_exists('content_fields')) {
+    include_once('./'. drupal_get_path('module', 'content') .'/content.module');
+    include_once('./'. drupal_get_path('module', 'content') .'/content_admin.inc');
+
+    $rename = array();
+
+    $types = content_types();
+    $fields = content_fields();
+
+    // "per content type" tables
+    foreach ($types as $type) {
+      $old_name = 'node_'. $type['type'];
+      $new_name = 'content_type_'. $type['type'];
+      if (db_table_exists($old_name)) {
+        if (!in_array($old_name, array('node_access',  'node_comments_statistics', 'node_counter', 'node_field', 'node_field_instance', 'node_group', 'node_group_fields', 'node_revisions', 'node_type'))) {
+          $rename[$old_name] = $new_name;
+        }
+        else {
+          // TODO : what ? create the table ?
+        }
+      }
+    }
+
+    // rename
+    foreach ($rename as $old_name => $new_name) {
+      switch ($GLOBALS['db_type']) {
+        case 'mysql':
+        case 'mysqli':
+          $ret[] = update_sql("RENAME TABLE {$old_name} TO {$new_name}");
+          break;
+
+        case 'pgsql':
+          $ret[] = update_sql("ALTER TABLE {$old_name} RENAME TO {$new_name}");
+          break;
+      }
+    }
+
+
+    // regenerate views
+    content_clear_type_cache();
+    if (module_exists('views')) {
+      include_once('./'. drupal_get_path('module', 'content') .'/content_views.inc');
+      $updated_views = _content_views_rebuild_views(array_keys(content_fields()));
+      foreach ($updated_views as $view) {
+        $ret[] = array(
+          'query' => strtr('The views %view has been regenerated.', array('%view' => $view)),
+          'success' => TRUE
+        );
+      }
+    }
+
+
+  }
+
+  return $ret;
+}
Index: content.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/cck/content.module,v
retrieving revision 1.90.2.27
diff -u -r1.90.2.27 content.module
--- content.module	18 Jan 2007 19:35:48 -0000	1.90.2.27
+++ content.module	19 Jan 2007 19:47:02 -0000
@@ -994,7 +994,7 @@
 function _content_tablename($name, $entity = 'type') {
   switch ($entity) {
     case 'type' :
-      return 'node_'.$name;
+      return 'content_type_'.$name;
     case 'field' :
       return 'node_data_'.$name;
   }
