Can not reference terms to media entity.

Created on 28 April 2023, almost 2 years ago

You are not allowed to use taxonomy terms like: "@termNames". Remove the restricted taxonomy terms from the form field and try again.

/**
 * Implements hook_form_alter().
 */
function permissions_by_term_form_alter(&$form, FormStateInterface $formState, $form_id) {
  $form['#validate'][] = 'permissions_by_term_validate';
  if (isNodeEditForm()) {
    $form['permissions_by_term_info'] = [

Validation is added for all forms but it should be added just for nodes.
Solution: move $form['#validate'][] = 'permissions_by_term_validate'; inside if statement.

πŸ› Bug report
Status

Active

Version

3.1

Component

Code

Created by

πŸ‡ΊπŸ‡¦Ukraine mmv93

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @mmv93
  • @mmv93 opened merge request.
  • @mmv93 opened merge request.
  • @mmv93 opened merge request.
  • πŸ‡¦πŸ‡ΉAustria tgoeg

    Seeing this as well but only on a production site although its dev site works flawlessly.
    The prod site did so until recently as well, so I don't know what happened.

    I may not view /taxonomy/term/1 anymore, either, not even as administrator.

    This is really weird.

    However, the changes in your commit do seem to solve it for me (at least I think I placed them in the right place (line 200 in src/Service/AccessCheck.php right now).

    I also see the following in the log:
    Path: /taxonomy/term/1. Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException: in Drupal\permissions_by_term\Listener\KernelEventListener->handleAccessToTaxonomyTermViewsPages() (line 217 of /var/www/drupal/web/modules/contrib/permissions_by_term/src/Listener/KernelEventListener.php).

    It only happens to this one term and I cannot seem to change that, even if I manually allow only one user to use this term (the settings just don't get saved).

    Found the problem, finally.

    We have a mixed taxonomy that defines the roles and possible other tags used for tagging pages. Now I know this is a bad idea.
    It seems some user mod assigned the term 1 as a role (although it is just a tag for promoting content to the front page in my case).

    This caused hell to break lose.

    I finally fixed it by
    - delete from permissions_by_term_user where tid=1;
    - Rebuilding node access permissions from the status page
    - Rebuilding cache

    This may be a different issue than the one described by OP, but a very similar outcome.

Production build 0.71.5 2024