'Delete selected terms' permission

Created on 29 June 2023, about 1 year ago
Updated 7 July 2023, 12 months 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 12 months ago
  • πŸ‡²πŸ‡¦Morocco b.khouy πŸ‡²πŸ‡¦ Morocco
Production build 0.69.0 2024