Index: modules/comment/comment.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/comment/comment.module,v
retrieving revision 1.830
diff -u -p -r1.830 comment.module
--- modules/comment/comment.module	11 Jan 2010 16:25:16 -0000	1.830
+++ modules/comment/comment.module	12 Jan 2010 00:49:06 -0000
@@ -119,6 +119,16 @@ function comment_entity_info() {
   foreach (node_type_get_names() as $type => $name) {
     $return['comment']['bundles']['comment_node_' . $type] = array(
       'label' => $name,
+      'admin' => array(
+        // Place the Field UI paths for comments one level below the
+        // corresponding paths for nodes, so that they appear in the same set
+        // of local tabs. This is supported by custom workaround code in
+        // field_extract_bundle() and field_ui_menu_load().
+        'path' => 'admin/structure/types/manage/%node_type/comment',
+        'bundle argument' => 4,
+        'real path' => 'admin/structure/types/manage/' . str_replace('_', '-', $type) . '/comment',
+        'access arguments' => array('administer content types'),
+      ),
     );
   }
 
@@ -126,6 +136,43 @@ function comment_entity_info() {
 }
 
 /**
+ * Implements hook_field_extract_bundle_alter().
+ */
+function comment_field_extract_bundle_alter(&$bundle_name, $obj_type, $field_name = NULL) {
+  // Handle the specific case of comments, for which the bundle name received
+  // is the name of the node type.
+  if ($obj_type == 'comment' && strpos($bundle_name, 'comment_node_') !== 0) {
+    $bundle_name = 'comment_node_' . $bundle_name;
+  }
+}
+
+/**
+ * Implements hook_field_extra_fields().
+ */
+function comment_field_extra_fields() {
+  $return = array();
+
+  foreach (node_type_get_types() as $type) {
+    if (variable_get('comment_subject_field_' . $type->type, 1) == 1) {
+      $return['comment']['comment_node_' . $type->type] = array(
+        'author' => array(
+          'label' => t('Author'),
+          'description' => t('Author textfield'),
+          'weight' => -2,
+        ),
+        'title' => array(
+          'label' => t('Subject'),
+          'description' => t('Subject textfield'),
+          'weight' => -1,
+        ),
+      );
+    }
+  }
+
+  return $return;
+}
+
+/**
  * Implements hook_theme().
  */
 function comment_theme() {
@@ -2488,6 +2535,12 @@ function comment_ranking() {
 function comment_menu_alter(&$items) {
   // Add comments to the description for admin/content.
   $items['admin/content']['description'] = "View, edit, and delete your site's content and comments.";
+
+  // Adjust the Field UI tabs on admin/structure/types/manage/[node-type].
+  $items['admin/structure/types/manage/%node_type/comment/fields']['title'] = 'Comment fields';
+  $items['admin/structure/types/manage/%node_type/comment/fields']['weight'] = 3;
+  $items['admin/structure/types/manage/%node_type/comment/display']['title'] = 'Comment display';
+  $items['admin/structure/types/manage/%node_type/comment/display']['weight'] = 4;
 }
 
 /**
Index: modules/field/field.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/field/field.module,v
retrieving revision 1.60
diff -u -p -r1.60 field.module
--- modules/field/field.module	4 Jan 2010 21:31:52 -0000	1.60
+++ modules/field/field.module	12 Jan 2010 00:47:26 -0000
@@ -736,7 +736,9 @@ function field_extract_bundle($obj_type,
 
   $info = entity_get_info($obj_type);
   if (is_object($bundle) && isset($info['bundle keys']['bundle']) && isset($bundle->{$info['bundle keys']['bundle']})) {
-    return $bundle->{$info['bundle keys']['bundle']};
+    $bundle_name = $bundle->{$info['bundle keys']['bundle']};
+    drupal_alter('field_extract_bundle', $bundle_name, $obj_type);
+    return $bundle_name;
   }
 }
 
Index: modules/field_ui/field_ui.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/field_ui/field_ui.module,v
retrieving revision 1.22
diff -u -p -r1.22 field_ui.module
--- modules/field_ui/field_ui.module	3 Jan 2010 21:01:04 -0000	1.22
+++ modules/field_ui/field_ui.module	12 Jan 2010 00:47:58 -0000
@@ -139,6 +139,8 @@ function field_ui_menu() {
  */
 function field_ui_menu_load($field_name, $obj_type, $bundle_name) {
   $bundle_name = strtr($bundle_name, array('-' => '_'));
+  drupal_alter('field_extract_bundle', $bundle_name, $obj_type, $field_name);
+
   if ($instance = field_info_instance($obj_type, $field_name, $bundle_name)) {
     return $instance;
   }
