'Delete selected terms' permission

Created on 29 June 2023, almost 2 years ago
Updated 7 July 2023, almost 2 years ago

Problem/Motivation

The 'Delete selected terms' action now relies on the 'administer taxonomy' permission.
But users who do not have that permission, but do have permission 'myvocabulary: Delete terms' should also be able to use to the 'Delete selected terms' action.

Steps to reproduce

- Create vocabulary 'myvocabulary' and add some terms
- Create a user role with permission: 'myvocabulary: Delete terms' and 'Access the taxonomy vocabulary overview page'
- Log in as a user with that role and go to /admin/structure/taxonomy/manage/myvocabulary/overview
- Notice that the 'Select an action' dropdown is empty instead of showing the 'Delete selected terms' action

🐛 Bug report
Status

Fixed

Version

1.0

Component

Code

Created by

🇧🇪Belgium flyke

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

Comments & Activities

  • Issue created by @flyke
  • 🇧🇪Belgium flyke

    Possible solution: change the access() function in /src/Plugin/TaxonomyBulkActions/TaxonomyBulkActionsDelete.php to:

      public function access(AccountProxyInterface $account) {
        // Check for delete permission for the current vocabulary.
        if ($vocabulary = \Drupal::routeMatch()->getParameter('taxonomy_vocabulary')) {
          $delete_permission = "delete terms in {$vocabulary->id()}";
          if ($account->hasPermission($delete_permission)) {
            return TRUE;
          }
        }
        // Check for the 'Administer vocabularies and terms' permission.
        return $account->hasPermission('administer taxonomy');
      }
  • 🇲🇦Morocco b.khouy 🇲🇦 Morocco

    Thanks @flyke for this issue report and proposed solutions.
    Fix has been deployed, for anyone facing the same issue please update to the latest module version >= 1.0.5
    composer require 'drupal/taxonomy_bulk_actions:^1.0'

  • 🇲🇦Morocco b.khouy 🇲🇦 Morocco
  • Status changed to Fixed almost 2 years ago
  • 🇲🇦Morocco b.khouy 🇲🇦 Morocco
Production build 0.71.5 2024