Any volunteers to port Taxonomy Permissions module from Drupal 7 to 8?

Related pages

We would be happy to contribute testing patch, quality assurance, documentation, and agile project management services if needed

Comments

Francewhoa created an issue. See original summary.

flocondetoile’s picture

I can give a try on a first port to D8.

I have some questions about how using the view permissions added on each vocabulary.

1. We can override the control Access class for each vocabulary, and then manage access to the taxonomy term at a low level. This means that if a user don't have permissions to view terms of a vocabulary, terms attached to a content (for example tags in the article content type) won't be displayed in the node
2. We can manage control access for each terms in vocabulary at a higher level, using event system, and prevent users who don't have permissions to view terms in a vocabulary to access to the taxonomy term page. But they will be able to view terms displayed in a node page

Any thought ?

flocondetoile’s picture

@salvis could you create a 8.x-1.x branch ?

salvis’s picture

Version: 7.x-1.x-dev » 8.x-1.x-dev

Great, welcome flocondetoile!
And thank you for your offer to help, Francewhoa!

I've just created the 8.x-1.x branch.

The front page says this about TP:

Roles without the 'view' permission for a given vocabulary will not see Taxonomy Term Reference fields for that vocabulary, and they will not be able to access the taxonomy/term/% pages for the terms in that vocabulary.

So, to be consistent, #1 is the way to go.

Would #2 be useful? If term references are shown as links, this would mean converting them to plain text. I guess if we wanted to see term references, we could add a second set of permissions, something like see terms in vocabulary, but this would be a new feature.

If you want, feel free to post a feature request for #2, then we can see whether there's any interest, but I'd prefer to just go with the existing functionality first.

flocondetoile’s picture

Status: Active » Needs review
StatusFileSize
new0 bytes

OK. Let's give a try and launch the tests included in the patch.
@salbis. Seems i can't launch the tests with 8.x-1.x (I've got only 7.x-1.x in the select list to launch test) ?

flocondetoile’s picture

StatusFileSize
new25.9 KB

Sorry. Empty file. New patch attached.
Edit: Test will failed as they run against 7.x

Status: Needs review » Needs work

The last submitted patch, 6: 2606040-6.patch, failed testing.

flocondetoile’s picture

salvis’s picture

Sorry, I had to enable testing for D8 — and it passed!

  1. +++ b/taxonomy_permissions.module
    @@ -5,121 +5,92 @@
    +      $output .= '<p>' . t("Taxonomy Permissions adds 'view terms in
    +       %vocabulary%' permissions to the list of permissions of the Taxonomy ¶
    +       core module.") . '</p>';
    +      $output .= '<p>' . t("To avoid surprises, vocabularies are visible by ¶
    +       authenticated and anonymous users by default. You have to change the ¶
    +       permissions to see any effect of this module.") . '</p>';
    +      return $output;
    

    There's a problem here. Seems like your editor wrapped the lines in the middle of string constants.

    Maybe this happened in other places, too.

  2. +++ b/taxonomy_permissions.permissions.yml
    @@ -0,0 +1,2 @@
    +permission_callbacks:
    +  - \Drupal\taxonomy_permissions\TaxonomyPermissions::permissions
    \ No newline at end of file
    

    Many tools don't like that.

flocondetoile’s picture

StatusFileSize
new25.88 KB

Thanks for you feedback. I fixed issues mentionned. Patch attached.

flocondetoile’s picture

Status: Needs work » Needs review

Let's the bot test it.

guysaban’s picture

Hi, I wanted to try this new module but the D8 module link looks like Drupal 7 module but is the info files says its D8.
How to I apply the patch if there is no src folder?

salvis’s picture

@guysaban: Thank you for your interest, but your "D8 module link" points to a completely different module...

dravenk’s picture

Status: Needs review » Reviewed & tested by the community

I tested this patch. People got the 404 message if people without access permission. Change the state to the RTBC.

rob c’s picture

Status: Reviewed & tested by the community » Needs work

But the patch needs more work i believe.

I see unused 'use' statements and some other coding style issues, tests are simpletests, etc.

I'm updating the patch right now (see how far i'll get today).

dravenk’s picture

StatusFileSize
new3.05 KB
new26 KB

Little work

rob c’s picture

Status: Needs work » Needs review
StatusFileSize
new27.29 KB
new27.32 KB

And a bit more work, including #16.
Moves tests to unit>functional (the start).
Other minor coding style issues (use phpcs to test).

Status: Needs review » Needs work

The last submitted patch, 17: 2606040-17.patch, failed testing. View results

rob c’s picture

21:23:25 Attempting to connect to database server.
21:23:26 Could not connect to database server.
To bad, they work locally.

sudo -u user -E ../bin/phpunit -c core --debug --verbose --group taxonomy_permissions
PHPUnit 4.8.36 by Sebastian Bergmann and contributors.

Runtime:	PHP 7.1.4 with Xdebug 2.5.3
Configuration:	/web/core/phpunit.xml


Starting test 'Drupal\Tests\taxonomy_permissions\Functional\TaxonomyPermissionsTestBase::testViewTerm'.
.
Starting test 'Drupal\Tests\taxonomy_permissions\Functional\TaxonomyPermissionsTestBase::testAccessTermPage'.
.
Starting test 'Drupal\Tests\taxonomy_permissions\Functional\TaxonomyPermissionsTestBase::testAccessFormTerm'.
.

Time: 50.13 seconds, Memory: 220.00MB

OK (3 tests, 33 assertions)
rob c’s picture

Status: Needs work » Needs review
rob c’s picture

@salvis we'r still testing with php 5.5?

Status: Needs review » Needs work

The last submitted patch, 17: 2606040-17.patch, failed testing. View results

dravenk’s picture

StatusFileSize
new27.33 KB

@Rob C
thanks for work in this.
I'm learning and do a small little work for this.
make more green.

salvis’s picture

Priority: Normal » Major

@salvis we'r still testing with php 5.5?

Yes, D8 supports PHP 5.5: https://www.drupal.org/docs/7/system-requirements/php

And that doesn't seem to be the roadblock.

Thanks to all for working on this!

anybody’s picture

Should this perhaps be combined into taxonomy_access_fix module for Drupal 8? See #2949043: Add missing "View terms in %vocabulary" permission

anybody’s picture

Is there an active maintainer willing to maintain the D8 branch? Wouldn't it make sense to commit the latest patch to the 8.x-1.x-dev branch? Currently that contains D8 code which is even a worse starting point? Patches would become smaller and more readable then?

salvis’s picture

Category: Plan » Task
Status: Needs work » Needs review
StatusFileSize
new3.47 KB
new26.21 KB

Should this perhaps be combined into taxonomy_access_fix module for Drupal 8?

Yes, that could be a way to go.

Wouldn't it make sense to commit the latest patch to the 8.x-1.x-dev branch?

Well, I would like to have a green patch...

Let's try this...

  • salvis committed ff62acf on 8.x-1.x authored by flocondetoile
    Issue #2606040 by flocondetoile, Rob C, dravenk, salvis: Port Taxonomy...
salvis’s picture

Does anyone have an idea why the D8.4.5 test fails?

P.S. DON'T try to rerun the test on the patch, because #27 obviously cannot be applied a second time after it has been committed.

salvis’s picture

anybody’s picture

FYI: #2949043: Add missing "View terms in %vocabulary" permission was just fixed :) So you may choose now!

rob c’s picture

@salvis could you trigger a test with 8.3? Got an idea why it fails, see if the testbot agrees.

salvis’s picture

Status: Needs review » Fixed

The testbot doesn't support 8.3 anymore, only 8.4 to 8.6, at this point.

8.5.0 passed and is now the stable version, so I guess we don't need to worry about 8.4 anymore.

rob c’s picture

To bad, i can retest still with 8.3 on some projects.

And prolly true, 8.4 is out anyway, but for the people still looking.

I think it's because of an issue fixed in 8.2 for minor issues with cache tags (forgot the issue number). In 8.5 another patch was added to core for this, that's why 8.5 does not break anymore i believe.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

francewhoa’s picture

Thanks all for your contributions :)

This is a note to myself. I updated this ticket attribution tags.

sebaz’s picture

When release, maybe D9 compatibility is only change in info.yml?

code on git https://git.drupalcode.org/project/taxonomy_permissions/-/tree/8.x-1.x/

rossidrup’s picture

is this module ready for drupal 9 and commerce? to hide products with specific terms?

raajkumar.kuru’s picture

StatusFileSize
new3.59 KB

Here is the Patch for Drupal 10