Index: modules/filter/filter.install
===================================================================
RCS file: /cvs/drupal/drupal/modules/filter/filter.install,v
retrieving revision 1.17
diff -u -r1.17 filter.install
--- modules/filter/filter.install	21 Aug 2009 17:28:26 -0000	1.17
+++ modules/filter/filter.install	21 Aug 2009 21:45:45 -0000
@@ -10,50 +10,6 @@
  * Implement hook_schema().
  */
 function filter_schema() {
-  $schema['filter'] = array(
-    'description' => 'Table that maps filters (HTML corrector) to text formats (Filtered HTML).',
-    'fields' => array(
-      'fid' => array(
-        'type' => 'serial',
-        'not null' => TRUE,
-        'description' => 'Primary Key: Auto-incrementing filter ID.',
-      ),
-      'format' => array(
-        'type' => 'int',
-        'not null' => TRUE,
-        'default' => 0,
-        'description' => 'Foreign key: The {filter_format}.format to which this filter is assigned.',
-      ),
-      'module' => array(
-        'type' => 'varchar',
-        'length' => 64,
-        'not null' => TRUE,
-        'default' => '',
-        'description' => 'The origin module of the filter.',
-      ),
-      'name' => array(
-        'type' => 'varchar',
-        'length' => 32,
-        'not null' => TRUE,
-        'default' => '',
-        'description' => 'Name of the filter being referenced.',
-      ),
-      'weight' => array(
-        'type' => 'int',
-        'not null' => TRUE,
-        'default' => 0,
-        'size' => 'tiny',
-        'description' => 'Weight of filter within format.',
-      )
-    ),
-    'primary key' => array('fid'),
-    'unique keys' => array(
-      'fmn' => array('format', 'module', 'name'),
-    ),
-    'indexes' => array(
-      'list' => array('format', 'weight', 'module', 'name'),
-    ),
-  );
   $schema['filter_format'] = array(
     'description' => 'Stores text formats: custom groupings of filters, such as Filtered HTML.',
     'fields' => array(
@@ -69,6 +25,12 @@
         'default' => '',
         'description' => 'Name of the text format (Filtered HTML).',
       ),
+      'filters' => array(
+        'description' => 'A serialized ordered array containing the filters enabled in the format.',
+        'type' => 'text',
+        'not null' => FALSE,
+        'size' => 'normal',
+      ),      
       'roles' => array(
         'type' => 'varchar',
         'length' => 255,
@@ -187,3 +149,31 @@
   return $ret;
 }
 
+/**
+ * Remove {filter} table.
+ */
+function filter_update_7004() {
+  $ret = array();
+  
+  //  Add a filters column to the {filter_format} table.
+  db_add_field($ret, 'filter_format', 'filters', array(
+    'description' => 'A serialized ordered array containing the filters enabled in the format.',
+    'type' => 'text',
+    'not null' => FALSE,
+    'size' => 'normal',
+  ));
+  
+  // Loop through each format and collect the filters enabled.
+  $formats = db_query("SELECT format FROM {filter_format}")->fetchCol();
+  foreach ($formats as $format) {
+    $filters = db_query("SELECT name FROM {filter} WHERE format = :format ORDER BY weight ASC", array(':format' => $format))->fetchCol();
+    $filters = serialize($filters);
+    // Save the serialized filters array to the table.
+    $ret[] = update_sql("UPDATE {filter_format} SET filters = '" . $filters . "' WHERE format = " . $format);
+  }
+  
+  db_drop_table($ret, 'filter');
+  
+  return $ret;
+}
+
Index: modules/filter/filter.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/filter/filter.module,v
retrieving revision 1.272
diff -u -r1.272 filter.module
--- modules/filter/filter.module	21 Aug 2009 17:28:26 -0000	1.272
+++ modules/filter/filter.module	21 Aug 2009 21:45:54 -0000
@@ -299,13 +299,9 @@
   if (!isset($formats)) {
     $formats = array();
 
-    $query = db_select('filter_format', 'f');
-    $query->addField('f', 'format', 'format');
-    $query->addField('f', 'name', 'name');
-    $query->addField('f', 'roles', 'roles');
-    $query->addField('f', 'cache', 'cache');
-    $query->addField('f', 'weight', 'weight');
-    $query->orderBy('weight');
+    $query = db_select('filter_format', 'f')
+      ->fields('f')
+      ->orderBy('weight');
 
     // Build query for selecting the format(s) based on the user's roles.
     if (!$all) {
@@ -316,7 +312,12 @@
       $query->condition($or);
     }
 
-    $formats = $query->execute()->fetchAllAssoc('format');
+    $result = $query->execute();
+    foreach ($result as $format) {
+      // Get an array filters enabled, ordered properly.
+      $format->filters = unserialize($format->filters);
+      $formats[$format->format] = $format;
+    }
   }
   if (isset($index)) {
     return isset($formats[$index]) ? $formats[$index] : FALSE;
@@ -374,27 +375,6 @@
 }
 
 /**
- * Retrieve a list of filters for a certain format.
- */
-function filter_list_format($format) {
-  static $filters = array();
-
-  if (!isset($filters[$format])) {
-    $filters[$format] = array();
-    $result = db_query("SELECT * FROM {filter} WHERE format = :format ORDER BY weight, module, name", array(':format' => (int) $format));
-    foreach ($result as $filter) {
-      $info = module_invoke($filter->module, 'filter_info');
-      if (isset($info) && is_array($info) && isset($info[$filter->name])) {
-        $filter->title = $info[$filter->name]['title'];
-        $filters[$format][$filter->module . '/' . $filter->name] = $filter;
-      }
-    }
-  }
-
-  return $filters[$format];
-}
-
-/**
  * @name Filtering functions
  * @{
  * Modules which need to have content filtered can use these functions to
