#914458: remove the text format reassignment feature.

From: Damien Tournoud <damien@commerceguys.com>


---
 block/block.module                  |   10 ----------
 field/modules/text/text.module      |    3 ---
 filter/filter.admin.inc             |   16 +---------------
 filter/filter.api.php               |   15 ++-------------
 filter/filter.module                |   12 ++----------
 simpletest/tests/filter_test.module |    2 +-
 user/user.module                    |   10 ----------
 7 files changed, 6 insertions(+), 62 deletions(-)

diff --git modules/block/block.module modules/block/block.module
index 5c05334..f701482 100644
--- modules/block/block.module
+++ modules/block/block.module
@@ -955,16 +955,6 @@ function block_user_role_delete($role) {
 }
 
 /**
- * Implements hook_filter_format_delete().
- */
-function block_filter_format_delete($format, $fallback) {
-  db_update('block_custom')
-    ->fields(array('format' => $fallback->format))
-    ->condition('format', $format->format)
-    ->execute();
-}
-
-/**
  * Implements hook_menu_delete().
  */
 function block_menu_delete($menu) {
diff --git modules/field/modules/text/text.module modules/field/modules/text/text.module
index 4bbabcc..da6dc57 100644
--- modules/field/modules/text/text.module
+++ modules/field/modules/text/text.module
@@ -606,9 +606,6 @@ function text_filter_format_update() {
 
 /**
  * Implements hook_filter_format_delete().
- *
- * @todo D8: Properly update filter format references in all fields. See
- *   http://drupal.org/node/556022 for details.
  */
 function text_filter_format_delete() {
   field_cache_clear();
diff --git modules/filter/filter.admin.inc modules/filter/filter.admin.inc
index e793b69..0a266b6 100644
--- modules/filter/filter.admin.inc
+++ modules/filter/filter.admin.inc
@@ -322,20 +322,6 @@ function filter_admin_format_form_submit($form, &$form_state) {
 function filter_admin_delete($form, &$form_state, $format) {
   $form['#format'] = $format;
 
-  $fallback_options = array();
-  foreach (filter_formats() as $id => $fallback_format) {
-    if ($id != $format->format) {
-      $fallback_options[$id] = $fallback_format->name;
-    }
-  }
-  $form['fallback'] = array(
-    '#type' => 'select',
-    '#title' => t('Replacement text format'),
-    '#options' => $fallback_options,
-    '#default_value' => filter_fallback_format(),
-    '#description' => t('Content assigned to the deleted text format will be reassigned to the chosen one.'),
-  );
-
   return confirm_form($form,
     t('Are you sure you want to delete the text format %format?', array('%format' => $format->name)),
     'admin/config/content/formats',
@@ -349,7 +335,7 @@ function filter_admin_delete($form, &$form_state, $format) {
  */
 function filter_admin_delete_submit($form, &$form_state) {
   $format = $form['#format'];
-  filter_format_delete($format, $form_state['values']['fallback']);
+  filter_format_delete($format);
   drupal_set_message(t('Deleted text format %format.', array('%format' => $format->name)));
 
   $form_state['redirect'] = 'admin/config/content/formats';
diff --git modules/filter/filter.api.php modules/filter/filter.api.php
index 95d79ef..c5c697f 100644
--- modules/filter/filter.api.php
+++ modules/filter/filter.api.php
@@ -235,25 +235,14 @@ function hook_filter_format_update($format) {
 /**
  * Perform actions when a text format has been deleted.
  *
- * All modules storing references to text formats have to implement this hook.
- *
- * When a text format is deleted, all content that previously had that format
- * assigned needs to be switched to the passed fallback format.
- *
  * @param $format
  *   The format object of the format being deleted.
- * @param $fallback
- *   The format object of the format to use as replacement.
  *
  * @see hook_filter_format_insert()
  * @see hook_filter_format_update()
  */
-function hook_filter_format_delete($format, $fallback) {
-  // Replace the deleted format with the fallback format.
-  db_update('my_module_table')
-    ->fields(array('format' => $fallback->format))
-    ->condition('format', $format->format)
-    ->execute();
+function hook_filter_format_delete($format) {
+  mymodule_cache_rebuild();
 }
 
 /**
diff --git modules/filter/filter.module modules/filter/filter.module
index d36253d..d87d032 100644
--- modules/filter/filter.module
+++ modules/filter/filter.module
@@ -260,12 +260,8 @@ function filter_format_save(&$format) {
  *
  * @param $format
  *   The text format object to be deleted.
- * @param $fallback_id
- *   (optional) The ID of the text format to use to reassign content that is
- *   currently using $format. If omitted, the currently stored
- *   filter_fallback_format() is used.
  */
-function filter_format_delete($format, $fallback_id = NULL) {
+function filter_format_delete($format) {
   db_delete('filter_format')
     ->condition('format', $format->format)
     ->execute();
@@ -274,11 +270,7 @@ function filter_format_delete($format, $fallback_id = NULL) {
     ->execute();
 
   // Allow modules to react on text format deletion.
-  if (empty($fallback_id)) {
-    $fallback_id = filter_fallback_format();
-  }
-  $fallback = filter_format_load($fallback_id);
-  module_invoke_all('filter_format_delete', $format, $fallback);
+  module_invoke_all('filter_format_delete', $format);
 
   // Clear the filter cache whenever a text format is deleted.
   filter_formats_reset();
diff --git modules/simpletest/tests/filter_test.module modules/simpletest/tests/filter_test.module
index 076c14a..b663882 100644
--- modules/simpletest/tests/filter_test.module
+++ modules/simpletest/tests/filter_test.module
@@ -23,7 +23,7 @@ function filter_test_filter_format_update($format) {
 /**
  * Implements hook_filter_format_delete().
  */
-function filter_test_filter_format_delete($format, $default) {
+function filter_test_filter_format_delete($format) {
   drupal_set_message('hook_filter_format_delete invoked.');
 }
 
diff --git modules/user/user.module modules/user/user.module
index 2e84c6e..28beadb 100644
--- modules/user/user.module
+++ modules/user/user.module
@@ -3602,16 +3602,6 @@ function user_modules_uninstalled($modules) {
 }
 
 /**
- * Implements hook_filter_format_delete().
- */
-function user_filter_format_delete($format, $fallback) {
-  db_update('users')
-    ->fields(array('signature_format' => $fallback->format))
-    ->condition('signature_format', $format->format)
-    ->execute();
-}
-
-/**
  * Helper function to rewrite the destination to avoid redirecting to login page after login.
  *
  * Third-party authentication modules may use this function to determine the
