Taxonomy Permissions are not saved when using "Save and go to list"

Created on 10 May 2024, 7 months ago
Updated 9 September 2024, 2 months ago

Problem/Motivation

For any taxonomy, when creating a new term, if saved use the "Save and go to list" button. The permission settings for user roles are not saved.

Drupal 10 (composer - 10.2.6)
Permissions by Term 3.1.33

Steps to reproduce

  1. Use a clean Drupal 10.2.6 installation
  2. Install and enable Permissions by Term v3.1.33 using composer composer require "drupal/permissions_by_term:3.1.33"
  3. Access as an administrator user.
  4. Navigate to the default "tags" taxonomy: /admin/structure/taxonomy/manage/tags/overview
  5. Click on "add term".
  6. Add some information and edit the permissions list.
  7. Click on "Save and go to list".
  8. Edit the term created and review the permissions
🐛 Bug report
Status

Needs work

Version

3.1

Component

Code

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

Comments & Activities

  • Issue created by @elbercastillomesa
  • After debugging I was able to notice that the actions for the $form[submit] element differ from the $form[overview] (which is the form element for the "Save and go to list" button.


    A "dirty" change and quick patch to include the "permissions_by_term_submit" action onto the list for the "Overview" element.

    If the change proposed could be improved, please don't hesitate and ping me, I'll be glad to learn.

  • Assigned to elbercastillomesa
  • Status changed to Needs review 7 months ago
  • Issue was unassigned.
  • 🇳🇴Norway gisle Norway

    Unassigning. We need another community member to review the patch.

  • 🇫🇮Finland anaconda777

    Hi,

    Applied patch, and tried to save again permissions for a term, but still it is not saved.

  • Status changed to Needs work 6 months ago
  • 🇳🇴Norway gisle Norway

    Setting status to "Needs work" based upon #6.

  • Assigned to Tyapchyc
  • 🇩🇪Germany Schoenef Unna

    Hi guys, I have the same problem with 3.1.33 and the patch also does not work for me. To me this is a pretty critical issue, as it kind of makes this version unusable.

    Some feedback would be great!

  • 🇩🇪Germany Schoenef Unna

    I also had a closer look now, and it looks like this happens for multi language setups. In my case the taxonomy had as language "not applicable", so the permissions by term are stored with langcode zxx - BUT when being loaded, it takes the current language (en) - so it is not found.

    extending the queries to pull also und and zxx languages might help, but I got a feeling that this would touch very much the core of this module and also potentially introduce bad side effects. However, it would be desirable to allow language independent access taxonomies for multi language sides.

    I did test this in web/modules/contrib/permissions_by_term/src/Service/AccessStorage.php:

    Before:

    public function getRoleTermPermissionsByTid($term_id, $langcode) {
        return $this->database->select('permissions_by_term_role', 'pr')
          ->condition('tid', $term_id)
          ->condition('langcode', $langcode)
          ->fields('pr', ['rid'])
          ->execute()
          ->fetchCol();
      }
    

    After (works as expected in the display, not tested further):

      public function getRoleTermPermissionsByTid($term_id, $langcode) {
        return $this->database->select('permissions_by_term_role', 'pr')
          ->condition('tid', $term_id)
          ->condition('langcode', [$langcode, 'und', 'zxx'], 'IN')
          ->fields('pr', ['rid'])
          ->execute()
          ->fetchCol();
      }
    

    The language is all over, so this would definitely require thorough retesting and an architecture decision/evaluation of the main maintainers.

    To make a long story short: Is there a way to support a language independent permission configuration in a multi language site?

    Thx a lot!

Production build 0.71.5 2024