If your node type is associated with one vocabulary which has only one term access to its node form will be denied. Adding another term will fix the problem.

To repeat:
1. Create a node type.
2. Create a vocab..
3. Create a term.
3. Install Term Permission.
4. Create a user account with limited permissions (i.e. not user 1) and switch to that account.
5. Go to node/add/yourcontenttype

You'll likely get "access denied".

If not, edit the term and set it to allow access by one or more of the roles the account you created in step 3 has. Try again. This should result in access denied.

To resolve:
1. Create a new term in the vocabulary you created in step 2.
2. Do not alter permission for this term, leave all roles unchecked.

Using the account you created in step 3 above, go to the node add form. Access granted!

Haven't had a chance to dig into this issue but it looks very much like a bug.

CommentFileSizeAuthor
#1 bug-1144614-1.patch641 bytessolipsist

Comments

solipsist’s picture

StatusFileSize
new641 bytes

I did some debugging. The cause of the error is the following line:

 $total_terms = count($vocabulary['#options']) - 1;

For a vocab with only one term, $total_terms will be assigned 0. That will trigger access denied further down:

          // If the user doesn't have access to any of the terms in the
          // vocabulary, remove the form item entirely.
          if ($total_terms <= 0) {
            if ($vocabulary['#required']) {
              drupal_set_message(t("Your account doesn't have permission to use any of the terms in the %vocabulary vocabulary. Your account must be given permission to use at least one term in the %vocabulary vocabulary to be able to add or edit the %content-type content type.", array('%vocabulary' => $vocabulary['#title'], '%content-type' => node_get_types('name', $form['type']['#value']))), 'warning');
              watchdog('term_permissions', '%user was blocked from accessing the %content-type form as they do not have permission to use any terms in the <a href="@vocabulary-url">%vocabulary</a> vocabulary.', array('%user' => isset($user->name) ? $user->name : variable_get('anonymous', 'Anonymous'), '%content-type' => node_get_types('name', $form['type']['#value']), '@vocabulary-url' => url('admin/content/taxonomy/' . $vid), '%vocabulary' => $vocabulary['#title']), WATCHDOG_WARNING, l(t('edit vocabulary'), 'admin/content/taxonomy/' . $vid));
              drupal_access_denied();
              exit();
            }
            unset($form['taxonomy'][$vid]);
          }
        }

I've attached a patch that fixes the problem.

deviantintegral’s picture

Status: Active » Postponed (maintainer needs more info)

Should have looked at this issue first. I think this is fixed as a part of #1369522: Fix off-by-one error when users have access to only one term. Can you verify that works for you as well?