Index: modules/forum/forum.install
===================================================================
RCS file: /cvs/drupal/drupal/modules/forum/forum.install,v
retrieving revision 1.48
diff -u -r1.48 forum.install
--- modules/forum/forum.install	24 Jun 2010 12:59:22 -0000	1.48
+++ modules/forum/forum.install	29 Jun 2010 05:25:07 -0000
@@ -25,6 +25,8 @@
  */
 function forum_enable() {
   // Create the forum vocabulary if it does not exist.
+  // Load the dependent Taxonomy module, in case it has been disabled.
+  drupal_load('module', 'taxonomy');
   $vocabulary = taxonomy_vocabulary_load(variable_get('forum_nav_vocabulary', 0));
   if (!$vocabulary) {
     $edit = array(
@@ -40,8 +42,9 @@
     variable_set('forum_nav_vocabulary', $vocabulary->vid);
   }
 
+  $field = field_read_field('taxonomy_' . $vocabulary->machine_name, array('include_inactive' => TRUE));
   // Create the 'taxonomy_forums' field if it doesn't already exist.
-  if (!field_info_field('taxonomy_forums')) {
+  if (!$field) {
     $field = array(
       'field_name' => 'taxonomy_' . $vocabulary->machine_name,
       'type' => 'taxonomy_term_reference',
@@ -56,28 +59,6 @@
     );
     field_create_field($field);
 
-    $instance = array(
-      'field_name' => 'taxonomy_' . $vocabulary->machine_name,
-      'entity_type' => 'node',
-      'label' => $vocabulary->name,
-      'bundle' => 'forum',
-      'required' => TRUE,
-      'widget' => array(
-        'type' => 'options_select',
-      ),
-      'display' => array(
-        'default' => array(
-          'type' => 'taxonomy_term_reference_link',
-          'weight' => 10,
-        ),
-        'teaser' => array(
-          'type' => 'taxonomy_term_reference_link',
-          'weight' => 10,
-        ),
-      ),
-    );
-    field_create_instance($instance);
-
     variable_set('forum_nav_vocabulary', $vocabulary->vid);
 
     // Create a default forum so forum posts can be created.
@@ -90,6 +71,35 @@
     $term = (object) $edit;
     taxonomy_term_save($term);
   }
+
+  // Re-enable the field we do this to get ronund the fact we might not have
+  // taxonomy in enable array if taxonomy has been enabled before forum and
+  // both module have been previously disabled.
+  field_associate_fields('taxonomy');
+
+  // Create the instance on the bundle.
+  $instance = array(
+    'field_name' => 'taxonomy_' . $vocabulary->machine_name,
+    'entity_type' => 'node',
+    'label' => $vocabulary->name,
+    'bundle' => 'forum',
+    'required' => TRUE,
+    'widget' => array(
+      'type' => 'options_select',
+    ),
+    'display' => array(
+      'default' => array(
+        'type' => 'taxonomy_term_reference_link',
+        'weight' => 10,
+      ),
+      'teaser' => array(
+        'type' => 'taxonomy_term_reference_link',
+        'weight' => 10,
+      ),
+    ),
+  );
+  field_create_instance($instance);
+
   // Ensure the forum node type is available.
   node_types_rebuild();
   $types = node_type_get_types();
