Problem
When we add two or more content types translated in Japanese (Asian) Language in the Group Node by installing the plugin from admin/group/types/manage//content and view the permissions by using admin/group/types/manage//permissions, only the fisrt content type name will be visible.
Steps to reproduce
1. Set Multilanugage drupal site.
2. Add Japanese Language
3. Add two or more content type and translate them in Japanese Language
4. Install Group Node Module
5. Add a group
6. Configure two or more content types that has been translated in Japanese Language for the newly created group.
7. View the permissions tab of the group.
8. Scroll down and you will see only Content Type name for only the first one.
Proposed resolution
1. The error is in the GroupPermissionsForm.php located in group\src\Form
2. Function name public function buildForm(array $form, FormStateInterface $form_state)
3. Line no 192 (in my installation) $section_id = $provider . '-' . preg_replace('/[^a-z0-9_]+/', '_', $section))
4. Cause. $section code gets the Name of the Group Node not the machine name. When preg_replace is used for Asian Language (Japanese in our case) the Gode Type name is replaced with null string thus all the $section_id has the same variable for all the groups thus when it loops to generate permission table it thinks it is the same Node Type as of the previous and does not create a new section.
5. Code I have added:
$section_keys= explode(" ",explode(":",array_pop(array_keys($permissions)))[1])[0]; (added)
$section_id = $provider . '-' . preg_replace('/[^a-z0-9_]+/', '_', $section)); (existing)
$section_id = $section_id.$section_keys; (added)
6. Explanation: I have added a line above the existing line that is line 192 in my case. The code will get the machine name of the Node Type and stored in $section_keys variable. I concatenated the $section_keys with the existing $section_id.
Remaining tasks
User interface changes
API changes
Data model changes
| Comment | File | Size | Author |
|---|---|---|---|
| fix-group-permission-asian-lng.patch | 727 bytes | Rastra Bhushan Khadka |
Issue fork group-3236626
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
kristiaanvandeneyndeGood catch, let's see if we can provide the sections with unique IDs though. This issue has clearly proven that using labels is error prone :)
Comment #6
alvar0hurtad0There's a MR with a possible solution.
https://git.drupalcode.org/project/group/-/merge_requests/50/diffs#note_...
Comment #7
kristiaanvandeneyndeI've removed a lot of boilerplate and allowed permissions to specify a section_id. Please test if everything still works okay.
In 2.0.0, we should just rework the permission handler to properly allow sections to be declared rather than having all of the permissions of a section have to define said section's label.
Comment #8
hagi commentedMR !50 with 2ae91a71 and a01b8d2f works for my Japanese environment. Thanks a lot.
Comment #9
alvar0hurtad0I've checked and works.
Comment #12
kristiaanvandeneyndeFixed and adding a follow-up to redo the system in 2.0.0