Index: modules/field/modules/text/text.test
===================================================================
RCS file: /cvs/drupal/drupal/modules/field/modules/text/text.test,v
retrieving revision 1.18
diff -u -p -r1.18 text.test
--- modules/field/modules/text/text.test	12 Feb 2010 05:38:10 -0000	1.18
+++ modules/field/modules/text/text.test	15 Feb 2010 21:50:19 -0000
@@ -195,7 +195,7 @@ class TextFieldTestCase extends DrupalWe
     $format_id = db_query("SELECT format FROM {filter_format} WHERE name = :name", array(':name' => $edit['name']))->fetchField();
     $permission = filter_permission_name(filter_format_load($format_id));
     $rid = max(array_keys($this->web_user->roles));
-    user_role_grant_permissions($rid, array($permission), TRUE);
+    user_role_grant_permissions($rid, array($permission));
     $this->drupalLogin($this->web_user);
 
     // Display edition form.
Index: modules/filter/filter.install
===================================================================
RCS file: /cvs/drupal/drupal/modules/filter/filter.install,v
retrieving revision 1.31
diff -u -p -r1.31 filter.install
--- modules/filter/filter.install	3 Feb 2010 18:16:23 -0000	1.31
+++ modules/filter/filter.install	15 Feb 2010 21:50:19 -0000
@@ -107,6 +107,42 @@ function filter_schema() {
 }
 
 /**
+ * Implements hook_install().
+ */
+function filter_install() {
+  // All sites require at least one text format (the fallback format) that all
+  // users have access to, so add it here. We initialize it as a simple, safe
+  // plain text format with very basic formatting, but it can be modified by
+  // installation profiles to have other properties.
+  $plain_text_format = array(
+    'name' => 'Plain text',
+    'weight' => 10,
+    'filters' => array(
+      // Escape all HTML.
+      'filter_html_escape' => array(
+        'weight' => 0,
+        'status' => 1,
+      ),
+      // URL filter.
+      'filter_url' => array(
+        'weight' => 1,
+        'status' => 1,
+      ),
+      // Line break filter.
+      'filter_autop' => array(
+        'weight' => 2,
+        'status' => 1,
+      ),
+    ),
+  );
+  $plain_text_format = (object) $plain_text_format;
+  filter_format_save($plain_text_format);
+
+  // Set the fallback format to plain text.
+  variable_set('filter_fallback_format', $plain_text_format->format);
+}
+
+/**
  * Implements hook_update_dependencies().
  */
 function filter_update_dependencies() {
@@ -316,18 +352,27 @@ function filter_update_7005() {
   $start_name = 'Plain text';
   $format_name = $start_name;
   while ($format = db_query('SELECT format FROM {filter_format} WHERE name = :name', array(':name' => $format_name))->fetchField()) {
-    $id = empty($id) ? 1 : $id + 1;
+    $id = empty($id) ? 2 : $id + 1;
     $format_name = $start_name . ' ' . $id;
   }
   $fallback_format = new stdClass();
   $fallback_format->name = $format_name;
-  $fallback_format->cache = 1;
   $fallback_format->weight = 1;
   // This format should output plain text, so we escape all HTML and apply the
-  // line break filter only.
+  // line break and URL filters only.
   $fallback_format->filters = array(
-    'filter_html_escape' => array('status' => 1),
-    'filter_autop' => array('status' => 1),
+    'filter_html_escape' => array(
+      'weight' => 0,
+      'status' => 1,
+    ),
+    'filter_url' => array(
+      'weight' => 1,
+      'status' => 1,
+    ),
+    'filter_autop' => array(
+      'weight' => 2,
+      'status' => 1,
+    ),
   );
   filter_format_save($fallback_format);
   variable_set('filter_fallback_format', $fallback_format->format);
Index: modules/filter/filter.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/filter/filter.module,v
retrieving revision 1.315
diff -u -p -r1.315 filter.module
--- modules/filter/filter.module	30 Jan 2010 22:47:24 -0000	1.315
+++ modules/filter/filter.module	15 Feb 2010 21:50:19 -0000
@@ -153,14 +153,17 @@ function filter_format_load($format_id) 
  *   - 'name': The title of the text format.
  *   - 'format': (optional) The internal ID of the text format. If omitted, a
  *     new text format is created.
- *   - 'roles': (optional) An associative array containing the roles allowed to
- *     access/use the text format.
+ *   - 'weight': (optional) The weight of the text format, which controls its
+ *     placement in text format lists. If omitted, the weight is set to 0.
  *   - 'filters': (optional) An associative, multi-dimensional array of filters
- *     assigned to the text format, using the properties:
- *     - 'weight': The weight of the filter in the text format.
- *     - 'status': A boolean indicating whether the filter is enabled in the
- *       text format.
- *     - 'module': The name of the module implementing the filter.
+ *     assigned to the text format, keyed by the name of each filter and using
+ *     the properties:
+ *     - 'weight': (optional) The weight of the filter in the text format. If
+ *       omitted, either the currently stored weight is retained (if there is
+ *       one), or the filter is assigned a weight of 10, which will usually
+ *       put it at the bottom of the list.
+ *     - 'status': (optional) A boolean indicating whether the filter is
+ *       enabled in the text format. If omitted, the filter will be disabled.
  *     - 'settings': (optional) An array of configured settings for the filter.
  *       See hook_filter_info() for details.
  */
@@ -439,6 +442,31 @@ function filter_default_format($account 
 
 /**
  * Returns the ID of the fallback text format that all users have access to.
+ *
+ * The fallback text format is a regular text format in every respect, except
+ * it does not participate in the filter permission system and cannot be
+ * deleted. It needs to exist because any user who has permission to create
+ * formatted content must always have at least one text format they can use.
+ *
+ * Because the fallback format is available to all users, it should always be
+ * configured securely. For example, when the Filter module is installed, this
+ * format is initialized to output plain text. Installation profiles and site
+ * administrators have the freedom to configure it further.
+ *
+ * When a text format is deleted, all content that previously had that format
+ * assigned should be switched to the fallback format. To facilitate this,
+ * Drupal passes in the fallback format object as one of the parameters of
+ * hook_filter_format_delete().
+ *
+ * Note that the fallback format is completely distinct from the default
+ * format, which differs per user and is simply the first format which that
+ * user has access to. The default and fallback formats are only guaranteed to
+ * be the same for users who do not have access to any other format; otherwise,
+ * the fallback format's weight determines its placement with respect to the
+ * user's other formats.
+ *
+ * @see hook_filter_format_delete()
+ * @see filter_default_format()
  */
 function filter_fallback_format() {
   // This variable is automatically set in the database for all installations
Index: profiles/minimal/minimal.install
===================================================================
RCS file: /cvs/drupal/drupal/profiles/minimal/minimal.install,v
retrieving revision 1.3
diff -u -p -r1.3 minimal.install
--- profiles/minimal/minimal.install	6 Feb 2010 16:30:27 -0000	1.3
+++ profiles/minimal/minimal.install	15 Feb 2010 21:50:19 -0000
@@ -7,29 +7,6 @@
  * Perform actions to set up the site for this profile.
  */
 function minimal_install() {
-  // Add text formats.
-  $plain_text_format = array(
-    'name' => 'Plain text',
-    'weight' => 10,
-    'filters' => array(
-      // Escape all HTML.
-      'filter_html_escape' => array(
-        'weight' => 0,
-        'status' => 1,
-      ),
-      // Line break filter.
-      'filter_autop' => array(
-        'weight' => 1,
-        'status' => 1,
-      ),
-    ),
-  );
-  $plain_text_format = (object) $plain_text_format;
-  filter_format_save($plain_text_format);
-
-  // Set the fallback format to plain text.
-  variable_set('filter_fallback_format', $plain_text_format->format);
-
   // Enable some standard blocks.
   $values = array(
     array(
Index: profiles/standard/standard.install
===================================================================
RCS file: /cvs/drupal/drupal/profiles/standard/standard.install,v
retrieving revision 1.6
diff -u -p -r1.6 standard.install
--- profiles/standard/standard.install	11 Feb 2010 03:29:22 -0000	1.6
+++ profiles/standard/standard.install	15 Feb 2010 21:50:19 -0000
@@ -61,28 +61,6 @@ function standard_install() {
   $full_html_format = (object) $full_html_format;
   filter_format_save($full_html_format);
 
-  $plain_text_format = array(
-    'name' => 'Plain text',
-    'weight' => 10,
-    'filters' => array(
-      // Escape all HTML.
-      'filter_html_escape' => array(
-        'weight' => 0,
-        'status' => 1,
-      ),
-      // Line break filter.
-      'filter_autop' => array(
-        'weight' => 1,
-        'status' => 1,
-      ),
-    ),
-  );
-  $plain_text_format = (object) $plain_text_format;
-  filter_format_save($plain_text_format);
-
-  // Set the fallback format to plain text.
-  variable_set('filter_fallback_format', $plain_text_format->format);
-
   // Enable some standard blocks.
   $values = array(
     array(
