Index: modules/forum/forum.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/forum/forum.module,v
retrieving revision 1.573
diff -u -p -r1.573 forum.module
--- modules/forum/forum.module	17 Aug 2010 16:20:07 -0000	1.573
+++ modules/forum/forum.module	27 Aug 2010 21:53:41 -0000
@@ -173,22 +173,28 @@ function forum_menu_local_tasks_alter(&$
     $forum_term = forum_forum_load($tid);
     if ($forum_term) {
       $vid = variable_get('forum_nav_vocabulary', 0);
-      $vocabulary = taxonomy_vocabulary_load($vid);
-
       $links = array();
-      // Loop through all bundles for forum taxonomy vocabulary field.
-      $field = field_info_field('taxonomy_' . $vocabulary->machine_name);
-      foreach ($field['bundles']['node'] as $type) {
-        if (node_access('create', $type)) {
-          $links[$type] = array(
-            '#theme' => 'menu_local_action',
-            '#link' => array(
-              'title' => t('Add new @node_type', array('@node_type' => node_type_get_name($type))),
-              'href' => 'node/add/' . str_replace('_', '-', $type) . '/' . $forum_term->tid,
-            ),
-          );
+      $fields = field_info_fields();
+      foreach ($fields as $field_name => $field) {
+        // Forum's vocabulary machine name can be changed by user so we can rely
+        // on it to find forum's field.
+        if (strpos($field_name, 'taxonomy_') === 0 && isset($field['settings']['allowed_values'][0]['vid']) && $field['settings']['allowed_values'][0]['vid'] == $vid) {
+          // Loop through all bundles for forum taxonomy vocabulary field.
+          foreach ($field['bundles']['node'] as $type) {
+            if (node_access('create', $type)) {
+              $links[$type] = array(
+                '#theme' => 'menu_local_action',
+                '#link' => array(
+                  'title' => t('Add new @node_type', array('@node_type' => node_type_get_name($type))),
+                  'href' => 'node/add/' . str_replace('_', '-', $type) . '/' . $forum_term->tid,
+                ),
+              );
+            }
+          }
+          break;
         }
       }
+
       if (empty($links)) {
         // Authenticated user does not have access to create new topics.
         if ($user->uid) {
