=== modified file 'modules/block/block.module'
--- modules/block/block.module	2010-09-24 02:01:56 +0000
+++ modules/block/block.module	2010-09-25 09:30:37 +0000
@@ -219,10 +219,12 @@ function block_block_info() {
  * Implements hook_block_configure().
  */
 function block_block_configure($delta = 0) {
-  $custom_block = array('format' => filter_default_format());
   if ($delta) {
     $custom_block = block_custom_block_get($delta);
   }
+  else {
+    $custom_block = array();
+  }
   return block_custom_block_form($custom_block);
 }
 

=== modified file 'modules/filter/filter.module'
--- modules/filter/filter.module	2010-09-24 00:37:41 +0000
+++ modules/filter/filter.module	2010-09-25 09:43:12 +0000
@@ -751,8 +751,8 @@ function check_markup($text, $format_id 
  *   The form element to process. Properties used:
  *   - #base_type: The form element #type to use for the 'value' element.
  *     'textarea' by default.
- *   - #format: (optional) The text format id to preselect. If 0, NULL, or not
- *     set, the default format for the current user will be used.
+ *   - #format: (optional) The text format id to preselect. If NULL or not set,
+ *     the default format for the current user will be used.
  *
  * @return
  *   The expanded element.
@@ -820,9 +820,10 @@ function filter_process_format($element)
   }
 
   // Use the default format for this user if none was selected.
-  if (empty($element['#format'])) {
+  if (!isset($element['#format'])) {
     $element['#format'] = filter_default_format($user);
   }
+
   $element['format']['format'] = array(
     '#type' => 'select',
     '#title' => t('Text format'),
@@ -841,12 +842,24 @@ function filter_process_format($element)
     '#weight' => 0,
   );
 
-  // Lastly, disallow editing of this field if the user is not allowed to use
-  // the stored and preselected text format. But only, if that format actually
-  // exists.
   $all_formats = filter_formats();
-  if (!isset($formats[$element['#format']]) && isset($all_formats[$element['#format']])) {
-    // Overload default values into #value to make them unalterable.
+  $format_exists = isset($all_formats[$element['#format']]);
+  $user_has_access = isset($formats[$element['#format']]);
+  $user_is_admin = user_access('administer filters');
+  // Administrators can edit any format, users can only edit the stored and
+  // preselected text format if it exists and they have access to it.
+  if ($user_is_admin || ($user_has_access && $format_exists)) {
+    // However, if the stored text format no longer exists then none of the
+    // text formats can be used as default value, so force the administrator
+    // to choose a new format. The previous condition enforces that only
+    // administrators can get here for non existing formats.
+    if (!$format_exists) {
+      $element['format']['format']['#default_value'] = NULL;
+    }
+  }
+  else {
+    // The user is not allowed to edit this format, soverload default values
+    // into #value to make them unalterable.
     $element['value']['#value'] = $element['value']['#default_value'];
     $element['format']['format']['#value'] = $element['format']['format']['#default_value'];
 

=== modified file 'modules/filter/filter.test'
--- modules/filter/filter.test	2010-09-18 02:18:35 +0000
+++ modules/filter/filter.test	2010-09-25 09:30:37 +0000
@@ -533,10 +533,35 @@ class FilterFormatAccessTestCase extends
     filter_format_disable($this->full_html_format);
     $this->resetFilterCaches();
 
-    // Verify that body field can be edited and a new format can be selected.
+    // Verify that the body field is now disabled, since the less privileged
+    // user should not be able to edit content that does not have an assigned
+    // format.
+    $this->drupalGet('node/' . $node->nid . '/edit');
+    $this->assertFieldByXPath("//textarea[@name='$body_value_key' and @disabled='disabled']", t('This field has been disabled because you do not have sufficient permissions to edit it.'), t('Text format access denied message found.'));
+
+    // Log back in as the administrator and verify that the body field can be
+    // edited.
+    $this->drupalLogin($this->admin_user);
     $this->drupalGet('node/' . $node->nid . '/edit');
     $this->assertNoFieldByXPath("//textarea[@name='$body_value_key' and @disabled='disabled']", NULL, t('Text format access denied message not found.'));
     $this->assertFieldByXPath("//select[@name='$body_format_key']", NULL, t('Text format selector found.'));
+
+    // Verify that trying to save the node without selecting a new text format
+    // produces an error message, and does not result in the node being saved.
+    $old_title = $new_edit['title'];
+    $new_title = $this->randomName(8);
+    $edit = array('title' => $new_title);
+    $this->drupalPost('node/' . $node->nid . '/edit', $edit, t('Save'));
+    $this->assertText(t('!name field is required.', array('!name' => t('Text format'))), t('Error message is displayed.'));
+    $this->drupalGet('node/' . $node->nid);
+    $this->assertText($old_title, t('Old title found.'));
+    $this->assertNoText($new_title, t('New title not found.'));
+
+    // Now select a new text format and make sure the node can be saved.
+    $edit[$body_format_key] = filter_fallback_format();
+    $this->drupalPost('node/' . $node->nid . '/edit', $edit, t('Save'));
+    $this->assertText($new_title, t('New title found.'));
+    $this->assertNoText($old_title, t('Old title not found.'));
   }
 
   /**

=== modified file 'modules/taxonomy/taxonomy.admin.inc'
--- modules/taxonomy/taxonomy.admin.inc	2010-07-31 13:01:50 +0000
+++ modules/taxonomy/taxonomy.admin.inc	2010-09-25 09:30:37 +0000
@@ -656,7 +656,7 @@ function taxonomy_form_term($form, &$for
     $defaults = array(
       'name' => '',
       'description' => '',
-      'format' => filter_default_format(),
+      'format' => NULL,
       'vocabulary_machine_name' => isset($vocabulary) ? $vocabulary->machine_name : NULL,
       'tid' => NULL,
       'weight' => 0,

=== modified file 'modules/user/user.install'
--- modules/user/user.install	2010-09-17 02:28:37 +0000
+++ modules/user/user.install	2010-09-25 09:30:37 +0000
@@ -169,8 +169,6 @@ function user_schema() {
       'signature_format' => array(
         'type' => 'int',
         'size' => 'small',
-        'not null' => TRUE,
-        'default' => 0,
         'description' => 'The {filter_format}.format of the signature.',
       ),
       'created' => array(
@@ -639,17 +637,31 @@ function user_update_7009() {
  * Update the {user}.signature_format column.
  */
 function user_update_7010() {
-  // It was previously possible for a value of "0" to be stored in database
-  // tables to indicate that a particular piece of text should be filtered
-  // using the default text format.
+  // In Drupal 6, the following situations could occur with text formats stored
+  // by modules in the database:
+  // - A value of "0" could be stored, indicating that a particular piece of
+  //   text would be filtered using whatever the site-wide default text format
+  //   was at the moment the text was being displayed.
+  // - A nonexistent text format could be stored (because the text format had
+  //   been deleted and the module did not have an opportunity to update its
+  //   data in response). This is the case for all contrib modules, but also
+  //   for the user signature format stored by core, due to a bug in Drupal 6
+  //   (http://drupal.org/node/863680). When filtering text with a nonexistent
+  //   format, Drupal 6 also treated it as though it had the site-wide default
+  //   format.
+  // In Drupal 7, all content must be stored with an explicit text format (or
+  // it will not be displayed when it is filtered). Therefore, to preserve the
+  // behavior of the site after the upgrade, we must replace all instances
+  // described above with the current value of the (old) site-wide default
+  // format at the moment of the upgrade.
+  $existing_formats = db_query("SELECT format FROM {filter_format}")->fetchCol();
   $default_format = variable_get('filter_default_format', 1);
   db_update('users')
     ->fields(array('signature_format' => $default_format))
-    ->condition('signature_format', 0)
+    ->condition('signature_format', $existing_formats, 'NOT IN')
     ->execute();
 }
 
-
 /**
  * Updates email templates to use new tokens.
  *
@@ -796,6 +808,22 @@ function user_update_7013(&$sandbox) {
 }
 
 /**
+ * Remove DEFAULT NOT NULL from {users}.signature_format column.
+ */
+function user_update_7014() {
+  db_change_field('users', 'signature_format', 'signature_format', array(
+    'type' => 'int',
+    'size' => 'small',
+    'description' => 'The {filter_format}.format of the signature.',
+  ));
+  // Replace all invalid rows referencing format 0 with NULL.
+  db_update('users')
+    ->fields(array('signature_format' => NULL))
+    ->condition('signature_format', 0)
+    ->execute();
+}
+
+/**
  * @} End of "defgroup user-updates-6.x-to-7.x"
  * The next series of updates should start at 8000.
  */

