Problem/Motivation
Permissions for taxonomy terms from an unchecked vocabulary remain active.
Steps to reproduce
1. You should have at least 2 vocabularies created. (For example: Vocabulary A and Vocabulary B)
2. On /admin/permissions-by-term/settings keep all vocabularies unchecked or check all vocabularies (in both cases this means that all are enabled).
3. Ensure that each vocabulary has at least one term with permissions set on its edit page.
4. Create test articles (for each term with permission form step 3).
5. Ensure that access to articles works correctly.
6. Go to the /admin/permissions-by-term/settings and keep checked only Vocabulary B.
Actual result: permission from Vocabulary B is still active, even if the user unchecked it on the settings page.
Expect result: permission from Vocabulary B should be reset and didn't affect access to the node.
Proposed resolution
On the /admin/permissions-by-term/settings page, when a user unchecks a vocabulary in Limit by taxonomy vocabularies, its permissions are reset.
Important: If the user unchecks all vocabularies, permissions are not reset. This means all vocabularies are considered enabled.
Issue fork permissions_by_term-3408309
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 #4
vitaliyb98 commentedProvided a function that resets term permission for unchecked vocabulary on /admin/permissions-by-term/settings (except cases when users unchecks all vocabularies which means all vocabularies are allowed)
Comment #5
vitaliyb98 commentedComment #6
vitaliyb98 commentedAdded Kernel and Functional tests for the new functionality.
I would appreciate any help with testing.
Comment #8
jepster_@vitaly98: I could successfully test this. Thanks!
I slightly modified the form, for not showing the status message above the setting. It looked a bit awkward. The warning is now in the standard help text below the setting checkbox.
I tried to run the unit tests locally. Including web/modules/custom/permissions_by_term/tests/src/Functional/VocabularyResetPermissionsTest.php
Therefor I run the tests from a basic Drupal 11 project with DDEV and the PHPUnit config file from Drupal core (and the PbTs config in doubt):
bin/phpunit -c web/core/phpunit.xml.dist web/modules/custom/permissions_by_term/tests
I got the following error:
I made the following directory existing and writeable: web/sites/simpletest/browser_output
This are my installed phpunit packages:
Comment #9
vitaliyb98 commentedHi @jepster_ , for local testing I usually use such command:
Comment #10
jepster_I have tried to this command, but I do still get this error:
Which PHPUnit version are you using? Please check like this: composer show | grep phpunit. Which Drupal version are you using?
Comment #11
vitaliyb98 commentedLooks like an issue in the PHPUnit version. My PHPUnit version is 11.5.22. (in the https://git.drupalcode.org/ pipelines 11.5.36).
For experimentation, I tried to run a test on PHPunit version 12.3.8 and received a similar error:
PHP Warning: Class "Drupal\TestTools\PhpUnitCompatibility\PhpUnit12\TestCompatibilityTrait" not found inComment #12
jepster_Now I do get this error:
Is the require-dev section of your composer.json file similar?
Tried to run it like this:
Comment #13
vitaliyb98 commentedMy dev section for my test project is (but not all of this is required for running the test), i guess in your case you need behat/mink-browserkit-driver
Comment #14
jepster_Thanks, now PHPUnit is not complaining about missing dependencies.
However, now all the tests are failing:
Since I do get the error "HTML output directory sites/simpletest/browser_output is not a writable directory.", I was also creating this directory and set it to chmod -R 777.
Comment #15
vitaliyb98 commentedIt’s weird, because in the MR pipelines all tests a successful. As I see, the test failing on the user login step, I guess some error is throw during logic process locally. In such cases I suggest to debug this test with xdebug or something like that, to detect problem.
Or as a first step run only this test with —debug option
Comment #16
jepster_Yes, it was the local command. The parameter for the database (sqllite) and the base url were wrong.
I ended up with this command on my DDEV setup:
The tests did pass. However, there are a couple of deprecation messages, which should be cleaned up some time.
Vitaly, could you please create a new patch release, since you merged a couple of MRs already?
Comment #17
jepster_Comment #20
vitaliyb98 commentedHi @jepster_ "Vitaly, could you please create a new patch release, since you merged a couple of MRs already?" - yes, that’s a good idea let’s plan to do it next week.