Index: modules/field/modules/text/text.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/field/modules/text/text.module,v
retrieving revision 1.36
diff -u -p -r1.36 text.module
--- modules/field/modules/text/text.module	11 Nov 2009 08:32:35 -0000	1.36
+++ modules/field/modules/text/text.module	21 Nov 2009 22:16:02 -0000
@@ -393,7 +393,7 @@ function text_summary($text, $format = N
   // parse errors.
   if (isset($format)) {
     $filters = filter_list_format($format);
-    if (isset($filters['php_code']) && strpos($text, '<?') !== FALSE) {
+    if (isset($filters['php_code']) && $filters['php_code']->status && strpos($text, '<?') !== FALSE) {
       return $text;
     }
   }
Index: modules/filter/filter.admin.inc
===================================================================
RCS file: /cvs/drupal/drupal/modules/filter/filter.admin.inc,v
retrieving revision 1.50
diff -u -p -r1.50 filter.admin.inc
--- modules/filter/filter.admin.inc	3 Nov 2009 05:27:18 -0000	1.50
+++ modules/filter/filter.admin.inc	21 Nov 2009 22:16:02 -0000
@@ -135,7 +135,7 @@ function filter_admin_format_form($form,
   }
   // Table with filters
   $filter_info = filter_get_filters();
-  $filters = filter_list_format($format->format, TRUE);
+  $filters = filter_list_format($format->format);
 
   $form['filters'] = array('#type' => 'fieldset',
     '#title' => t('Filters'),
@@ -260,12 +260,12 @@ function filter_admin_configure($form, &
 
   $form['#format'] = $format;
   foreach ($filters as $name => $filter) {
-    if (isset($filter_info[$name]['settings callback']) && function_exists($filter_info[$name]['settings callback'])) {
+    if ($filter->status && isset($filter_info[$name]['settings callback']) && function_exists($filter_info[$name]['settings callback'])) {
       // Pass along stored filter settings and default settings, but also the
       // format object and all filters to allow for complex implementations.
       $defaults = (isset($filter_info[$name]['default settings']) ? $filter_info[$name]['default settings'] : array());
       $settings_form = $filter_info[$name]['settings callback']($form, $form_state, $filters[$name], $defaults, $format, $filters);
-      if (isset($settings_form) && is_array($settings_form)) {
+      if (!empty($settings_form)) {
         $form['settings'][$name] = array(
           '#type' => 'fieldset',
           '#title' => check_plain($filter->title),
@@ -330,8 +330,10 @@ function filter_admin_order($form, &$for
 
   $form['weights'] = array('#tree' => TRUE);
   foreach ($filters as $id => $filter) {
-    $form['names'][$id] = array('#markup' => $filter->title);
-    $form['weights'][$id] = array('#type' => 'weight', '#default_value' => $filter->weight);
+    if ($filter->status) {
+      $form['names'][$id] = array('#markup' => $filter->title);
+      $form['weights'][$id] = array('#type' => 'weight', '#default_value' => $filter->weight);
+    }
   }
   $form['format'] = array('#type' => 'hidden', '#value' => $format->format);
   $form['submit'] = array('#type' => 'submit', '#value' => t('Save configuration'));
Index: modules/filter/filter.api.php
===================================================================
RCS file: /cvs/drupal/drupal/modules/filter/filter.api.php,v
retrieving revision 1.15
diff -u -p -r1.15 filter.api.php
--- modules/filter/filter.api.php	20 Sep 2009 07:32:17 -0000	1.15
+++ modules/filter/filter.api.php	21 Nov 2009 22:16:02 -0000
@@ -92,12 +92,12 @@
  *
  * @code
  *   function mymodule_filter_settings($form, &$form_state, $filter, $defaults) {
- *     $form['mymodule_url_length'] = array(
+ *     $settings['mymodule_url_length'] = array(
  *       '#type' => 'textfield',
  *       '#title' => t('Maximum link text length'),
  *       '#default_value' => isset($filter->settings['mymodule_url_length']) ? $filter->settings['mymodule_url_length'] : $defaults['mymodule_url_length'],
  *     );
- *     return $form;
+ *     return $settings;
  *   }
  * @endcode
  *
Index: modules/filter/filter.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/filter/filter.module,v
retrieving revision 1.300
diff -u -p -r1.300 filter.module
--- modules/filter/filter.module	23 Oct 2009 22:24:14 -0000	1.300
+++ modules/filter/filter.module	21 Nov 2009 22:20:39 -0000
@@ -191,9 +191,8 @@ function filter_format_save(&$format) {
     $return = drupal_write_record('filter_format', $format, 'format');
   }
 
-  // Get the filters currently active in the format, to add new filters
-  // to the bottom.
-  $current = filter_list_format($format->format, TRUE);
+  // Get the current filters in the format, to add new filters to the bottom.
+  $current = filter_list_format($format->format);
   $filter_info = filter_get_filters();
   if (!isset($format->filters)) {
     $format->filters = array();
@@ -506,11 +505,17 @@ function filter_format_allowcache($forma
 /**
  * Retrieve a list of filters for a given text format.
  *
+ * Note that this function returns all associated filters regardless of whether
+ * they are enabled or disabled. All functions working with the filter
+ * information outside of filter administration should test for $filter->status
+ * before performing actions with the filter.
+ *
  * @param $format_id
- *   The format ID.
+ *   The format ID to retrieve filters for.
  *
  * @return
- *   An array of filter objects assosiated to the given format.
+ *   An array of filter objects associated to the given text format, keyed by
+ *   filter name.
  */
 function filter_list_format($format_id) {
   $filters = &drupal_static(__FUNCTION__, array());
@@ -730,7 +735,7 @@ function _filter_tips($format_id, $long 
     $filters = filter_list_format($format->format);
     $tips[$format->name] = array();
     foreach ($filters as $name => $filter) {
-      if (isset($filter_info[$name]['tips callback']) && function_exists($filter_info[$name]['tips callback'])) {
+      if ($filter->status && isset($filter_info[$name]['tips callback']) && function_exists($filter_info[$name]['tips callback'])) {
         $tip = $filter_info[$name]['tips callback']($filter, $format, $long);
         $tips[$format->name][$name] = array('tip' => $tip, 'id' => $name);
       }
@@ -866,7 +871,7 @@ function filter_filter_info() {
  * Settings callback for the HTML filter.
  */
 function _filter_html_settings($form, &$form_state, $filter, $defaults) {
-  $form['allowed_html'] = array(
+  $settings['allowed_html'] = array(
     '#type' => 'textfield',
     '#title' => t('Allowed HTML tags'),
     '#default_value' => isset($filter->settings['allowed_html']) ? $filter->settings['allowed_html'] : $defaults['allowed_html'],
@@ -874,19 +879,19 @@ function _filter_html_settings($form, &$
     '#maxlength' => 1024,
     '#description' => t('Specify a list of tags which should not be stripped. (Note that JavaScript event attributes are always stripped.)'),
   );
-  $form['filter_html_help'] = array(
+  $settings['filter_html_help'] = array(
     '#type' => 'checkbox',
     '#title' => t('Display HTML help'),
     '#default_value' => isset($filter->settings['filter_html_help']) ? $filter->settings['filter_html_help'] : $defaults['filter_html_help'],
     '#description' => t('If enabled, Drupal will display some basic HTML help in the long filter tips.'),
   );
-  $form['filter_html_nofollow'] = array(
+  $settings['filter_html_nofollow'] = array(
     '#type' => 'checkbox',
     '#title' => t('Spam link deterrent'),
     '#default_value' => isset($filter->settings['filter_html_nofollow']) ? $filter->settings['filter_html_nofollow'] : $defaults['filter_html_nofollow'],
     '#description' => t('If enabled, Drupal will add rel="nofollow" to all links, as a measure to reduce the effectiveness of spam links. Note: this will also prevent valid links from being followed by search engines, therefore it is likely most effective when enabled for anonymous users.'),
   );
-  return $form;
+  return $settings;
 }
 
 /**
@@ -1012,14 +1017,14 @@ function _filter_html_tips($filter, $for
  * Settings callback for URL filter.
  */
 function _filter_url_settings($form, &$form_state, $filter, $defaults) {
-  $form['filter_url_length'] = array(
+  $settings['filter_url_length'] = array(
     '#type' => 'textfield',
     '#title' => t('Maximum link text length'),
     '#default_value' => isset($filter->settings['filter_url_length']) ? $filter->settings['filter_url_length'] : $defaults['filter_url_length'],
     '#maxlength' => 4,
     '#description' => t('URLs longer than this number of characters will be truncated to prevent long strings that break formatting. The link itself will be retained; just the text portion of the link will be truncated.'),
   );
-  return $form;
+  return $settings;
 }
 
 /**
Index: modules/filter/filter.test
===================================================================
RCS file: /cvs/drupal/drupal/modules/filter/filter.test,v
retrieving revision 1.47
diff -u -p -r1.47 filter.test
--- modules/filter/filter.test	10 Nov 2009 17:27:53 -0000	1.47
+++ modules/filter/filter.test	21 Nov 2009 22:16:02 -0000
@@ -111,7 +111,7 @@ class FilterCRUDTestCase extends DrupalW
     $this->assertTrue(empty($format_filters), t('Database contains values for all filters in the saved format.'));
 
     // Verify filter_list_format().
-    $filters = filter_list_format($format->format, TRUE);
+    $filters = filter_list_format($format->format);
     $format_filters = $format->filters;
     foreach ($filters as $name => $filter) {
       $t_args = array('%format' => $format->name, '%filter' => $name);
@@ -204,6 +204,22 @@ class FilterAdminTestCase extends Drupal
     $this->assertTrue(filter_access(filter_format_load($full), $this->admin_user), t('Admin user may use Full HTML.'));
     $this->assertFalse(filter_access(filter_format_load($full), $this->web_user), t('Web user may not use Full HTML.'));
 
+    // Verify that disabled filters are not displayed.
+    $edit = array();
+    $edit['filters[filter_url][status]'] = FALSE;
+    $this->drupalPost('admin/config/content/formats/' . $filtered, $edit, t('Save configuration'));
+    $this->drupalGet('admin/config/content/formats/' . $filtered . '/configure');
+    $this->assertNoText(t('Convert URLs into links'), t('Disabled URL filter cannot be configured.'));
+    $this->drupalGet('admin/config/content/formats/' . $filtered . '/order');
+    $this->assertNoText(t('Convert URLs into links'), t('Disabled URL filter cannot be re-ordered.'));
+    $edit = array();
+    $edit['filters[filter_url][status]'] = 1;
+    $this->drupalPost('admin/config/content/formats/' . $filtered, $edit, t('Save configuration'));
+    $this->drupalGet('admin/config/content/formats/' . $filtered . '/configure');
+    $this->assertText(t('Convert URLs into links'), t('Enabled URL filter can be configured.'));
+    $this->drupalGet('admin/config/content/formats/' . $filtered . '/order');
+    $this->assertText(t('Convert URLs into links'), t('Enabled URL filter can be re-ordered.'));
+
     // Add an additional tag.
     $edit = array();
     $edit['settings[filter_html][allowed_html]'] = '<a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <quote>';
@@ -243,15 +259,13 @@ class FilterAdminTestCase extends Drupal
     $format = $this->getFormat($edit['name']);
     $this->assertNotNull($format, t('Format found in database.'));
 
-    if ($format !== NULL) {
-      $this->assertFieldByName('roles[2]', '', t('Role found.'));
-      $this->assertFieldByName('filters[' . $second_filter . '][status]', '', t('Line break filter found.'));
-      $this->assertFieldByName('filters[' . $first_filter . '][status]', '', t('Url filter found.'));
-
-      // Delete new filter.
-      $this->drupalPost('admin/config/content/formats/' . $format->format . '/delete', array(), t('Delete'));
-      $this->assertRaw(t('Deleted text format %format.', array('%format' => $edit['name'])), t('Format successfully deleted.'));
-    }
+    $this->assertFieldByName('roles[2]', '', t('Role found.'));
+    $this->assertFieldByName('filters[' . $second_filter . '][status]', '', t('Line break filter found.'));
+    $this->assertFieldByName('filters[' . $first_filter . '][status]', '', t('Url filter found.'));
+
+    // Delete new filter.
+    $this->drupalPost('admin/config/content/formats/' . $format->format . '/delete', array(), t('Delete'));
+    $this->assertRaw(t('Deleted text format %format.', array('%format' => $edit['name'])), t('Format successfully deleted.'));
 
     // Allow authenticated users on full HTML.
     $format = filter_format_load($full);
