### Eclipse Workspace Patch 1.0
#P drupal7-cvs
Index: modules/block/block.admin.inc
===================================================================
RCS file: /cvs/drupal/drupal/modules/block/block.admin.inc,v
retrieving revision 1.47
diff -u -r1.47 block.admin.inc
--- modules/block/block.admin.inc	20 Jul 2009 18:51:32 -0000	1.47
+++ modules/block/block.admin.inc	22 Jul 2009 14:42:38 -0000
@@ -510,3 +510,15 @@
 
   $variables['form_submit'] = drupal_render_children($variables['form']);
 }
+
+/**
+ * Implement hook_format_delete().
+ */
+function block_format_delete($format) {
+  $default = variable_get('filter_default_format', 1);
+  // Replace existing instances of the deleted format with the default format.
+  db_update('box')
+    ->fields(array('format' => $default))
+    ->condition('format', $format)
+    ->execute();
+} 
\ No newline at end of file
Index: modules/comment/comment.admin.inc
===================================================================
RCS file: /cvs/drupal/drupal/modules/comment/comment.admin.inc,v
retrieving revision 1.26
diff -u -r1.26 comment.admin.inc
--- modules/comment/comment.admin.inc	1 Jul 2009 20:39:20 -0000	1.26
+++ modules/comment/comment.admin.inc	22 Jul 2009 14:42:39 -0000
@@ -292,3 +292,15 @@
     _comment_delete_thread($comment);
   }
 }
+
+/**
+ * Implement hook_format_delete().
+ */
+function comment_format_delete($format) {
+	$default = variable_get('filter_default_format', 1);
+  // Replace existing instances of the deleted format with the default format.
+  db_update('comment')
+    ->fields(array('format' => $default))
+    ->condition('format', $format)
+    ->execute();
+} 
\ No newline at end of file
Index: modules/filter/filter.api.php
===================================================================
RCS file: /cvs/drupal/drupal/modules/filter/filter.api.php,v
retrieving revision 1.8
diff -u -r1.8 filter.api.php
--- modules/filter/filter.api.php	24 May 2009 17:39:32 -0000	1.8
+++ modules/filter/filter.api.php	22 Jul 2009 14:42:48 -0000
@@ -159,5 +159,46 @@
 }
 
 /**
+ * Inform other modules that a text format has been updated.
+ *
+ * This hook allows you act when a text format has been updated in any way,
+ * for example, when filters have been recofigured, disabled, or re-arranged
+ * within the format.
+ *
+ * @see hook_format_delete().
+ *  
+ * @param $format
+ *   The format being updated.
+ *
+ */
+function hook_format_update($format) {
+  mymodule_cache_rebuild();
+} 
+
+/**
+ * Inform other modules that a text format has been deleted.
+ *
+ * This hook allows you act when a text format has been deleted.
+ * 
+ * It is recommended that you implement this hook if your module
+ * stores format references. Replace existing instances of the deleted
+ * format with the default format or other format.  
+ *
+ * @see hook_format_update().
+ *  
+ * @param $format
+ *   The format being deleted.
+ *
+ */
+function hook_format_delete($format) {
+  $default = variable_get('filter_default_format', 1);
+  // Replace existing instances of the deleted format with the default format.
+  db_update('my_module_table')
+    ->fields(array('format' => $default))
+    ->condition('format', $format)
+    ->execute();
+} 
+
+/**
  * @} End of "addtogroup hooks".
  */
Index: modules/filter/filter.admin.inc
===================================================================
RCS file: /cvs/drupal/drupal/modules/filter/filter.admin.inc,v
retrieving revision 1.30
diff -u -r1.30 filter.admin.inc
--- modules/filter/filter.admin.inc	12 Jun 2009 08:39:37 -0000	1.30
+++ modules/filter/filter.admin.inc	22 Jul 2009 14:42:48 -0000
@@ -261,6 +261,10 @@
     ->execute();
 
   cache_clear_all($format . ':', 'cache_filter', TRUE);
+  
+  if (!$new) {
+  	module_invoke_all('format_update', $format);
+  }
 
   // If a new filter was added, return to the main list of filters. Otherwise, stay on edit filter page to show new changes.
   $return = 'admin/settings/formats';
@@ -309,22 +313,8 @@
     ->condition('format', $form_state['values']['format'])
     ->execute();
 
-  $default = variable_get('filter_default_format', 1);
-  // Replace existing instances of the deleted format with the default format.
-  if (db_table_exists('comment')) {
-    db_update('comment')
-      ->fields(array('format' => $default))
-      ->condition('format', $form_state['values']['format'])
-      ->execute();
-  }
-  if (db_table_exists('box')) {
-    db_update('box')
-      ->fields(array('format' => $default))
-      ->condition('format', $form_state['values']['format'])
-      ->execute();
-  }
-
   cache_clear_all($form_state['values']['format'] . ':', 'cache_filter', TRUE);
+  module_invoke_all('format_delete', $form_state['values']['format']);
   drupal_set_message(t('Deleted text format %format.', array('%format' => $form_state['values']['name'])));
 
   $form_state['redirect'] = 'admin/settings/formats';
Index: modules/field/modules/text/text.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/field/modules/text/text.module,v
retrieving revision 1.15
diff -u -r1.15 text.module
--- modules/field/modules/text/text.module	3 Jul 2009 18:19:29 -0000	1.15
+++ modules/field/modules/text/text.module	22 Jul 2009 14:42:43 -0000
@@ -768,3 +768,11 @@
   }
 }
 
+/**
+ * Implement hook_format_delete().
+ */
+function text_format_delete($format) {
+  $default = variable_get('filter_default_format', 1);
+  // @TODO: Replace existing instances of the deleted format with the default format. (Fields in Core expert required)
+  
+} 
\ No newline at end of file
