Closed (fixed)
Project:
Permissions by Term
Version:
8.x-1.32
Component:
Code
Priority:
Major
Category:
Bug report
Assigned:
Reporter:
Created:
14 Sep 2017 at 08:59 UTC
Updated:
25 Nov 2017 at 11:49 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
harings_rob commentedThis should be fixed by the patch.
The issue was that the query failed to get correct results. This could happen when there are multiple taxonomy fields, where one is not even using term access.
This would always give back a node id because it is not matching the other list.
The patch solves this by checking using subqueries.
Comment #3
harings_rob commentedComment #4
harings_rob commentedComment #5
jepster_Thanks for patch and the report.
In your latest patch the $orGroup variable is undefined. Also it cannot be applied on the latest dev-version, because the AccessStorage service class code changed. Please be so kind and modify your patch, so that it can be applied.
Can you provide a test for this? If you are not able to create a test for this: can you describe a scenario for reproducing the issue?
Comment #6
Mark'Z commentedI have been following this issue, as I have the same problem, and was looking forward to the patch being part of the latest update (1.33). Sadly it wasn’t, but should really be part of the next one. Thank you harings_rob for providing the patch in the first place! :) I’d help out with it, but I have no coding skills.
Step-by-step to reproduce the issue using two taxonomy vocabularies (use default values unless otherwise specified):
Turn on “Single Term Restriction” in PbT Configuration screen
Create a taxonomy vocabulary
Create a term in this vocabulary and give it a user permission
Create a term in the Tags vocabulary with no permissions set
Create a content type
-Do not include a menu link
Add two taxonomy fields to the new content type
-One for the Tags taxonomy
-One for the taxonomy just created
Create a node using this new content type
-Assign one of the created terms to each of the taxonomy fields
Create a View
-View Settings: show “content” of type “all” tagged with “[term you created in Tags vocabulary]“
-Create a page with Display Settings: “unformatted list” of “full posts”
-Create a menu link on the “main navigation” menu
Log out
Log back in as a user who does not have permission to view created node
Click on menu link for the created View
The forbidden node should be visible in the view (showing it’s full content)
Click on the node
-page now displays “Access denied”
I have discovered that the same issue occurs with a single vocabulary with multiple terms.
To reproduce with only a single vocabulary:
Same general step-by-step as above, except...
Create a second term in the Tags vocabulary and give it a user permission
Create a content type with just one taxonomy field
-Use the Tags vocabulary with unlimited number of values
Create a node with the two created vocabulary terms
Create a View, using the term with no permissions, for View settings.
I hope this helps!
Comment #7
harings_rob commentedHi Mark'Z,
Thank you for your feedback.
I have to update the patch before this will get approved. (And actually the updated patch is now attached.)
Before the patch should be approved, we first have to write a test, the scenario you describe will help with that. Fortunately I do not have to much time.
I will set this issue to needs work in case someone feels like doing that.
Comment #8
matt bI get the following error having applied the patch to 8.x-1.33
Drupal\Core\Database\DatabaseExceptionWrapper: SQLSTATE[42000]: Syntax error or access violation: 1463 Non-grouping field 'inlist' is used in HAVING clause: SELECT n.nid AS nid FROM {node} n WHERE ((n.nid NOT IN (select CASE WHEN ti.tid IN (select tid from {permissions_by_term_role}) THEN ti.nid END as inlist FROM {taxonomy_index} ti HAVING inlist))) AND ((n.nid NOT IN (select CASE WHEN ti.tid IN (select tid from {permissions_by_term_user}) THEN ti.nid END as inlist FROM {taxonomy_index} ti HAVING inlist))); Array ( ) in Drupal\permissions_by_term\Service\AccessStorage->getNidsWithNoTidRestriction() (line 663 of /.../modules/contrib/permissions_by_term/src/Service/AccessStorage.php).Comment #9
jepster_Thanks for reporting and the patch! I will review the patch soon and run some tests.
Please check the latest release, which ensures that PbT is not handling any nodes, which are not related to taxonomy term permissions: https://www.drupal.org/project/permissions_by_term/releases/8.x-1.35. There might be problems solved, which are part of this issue.
Comment #10
jepster_Fixed query for retrieving all nodes with no term restriction. Also fixed kernel event listener for single node access, if an node has no related terms. In my manual tests I could not reproduce the issue anymore, after I have implemented the fix (before I could reproduce the issue - thanks for the steps). I will try to prepare an automated test, before this goes into release. You can see the edits in the following commit (own Git branch):
http://cgit.drupalcode.org/permissions_by_term/commit/?h=2908742&id=69b7...
And no worries: you will get the credits via my final Git commit. :)
Comment #11
jepster_I have added the test and pushed the changes into the dev branch. http://cgit.drupalcode.org/permissions_by_term/commit/?id=bdba065cb8935e...
I am closing this issue. Please feel free to re-open, if you have any further objections.
Comment #13
harings_rob commentedReopening this, I figured that this is incompatible within a certain mysql configuration.
Instead of asking users to modify that configuration we can improve the query a little bit.
Attached is the patch, tests should still run fine.
Comment #14
jepster_have you checked my git commit? i think i have solved that.
Comment #15
jepster_that's fixed. gets into next release. thanks everyone.
Comment #16
harings_rob commentedSorry Peter, but unless drupal git is showing the wrong information, this is not fixed:
http://cgit.drupalcode.org/permissions_by_term/commit/?id=bdba065cb8935e...
Mysql version: 5.7.19
Comment #17
jepster_Have you tested the latest dev branch with the mentioned Git commit? I have been fixing your first failing patch with the wrong sql statement.
Comment #18
harings_rob commentedYes I did test this on the latest dev version, that is also the place where I came across the error.
The patch I provided is based on the latest develop version of this module. This should be visible from the diff.
Looking here:
http://cgit.drupalcode.org/permissions_by_term/log/
The last commit is http://cgit.drupalcode.org/permissions_by_term/commit/?id=bdba065cb8935e...
Which is different from the patch that I provided (see group by).
The sql error was `Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column...`
Running Mysql version: 5.7.19
It might be that it cannot be reproduced on every configuration.
Extra information: https://stackoverflow.com/questions/34115174/error-related-to-only-full-...
Comment #20
jepster_@harings_rob: I have implemented your changes and tested it. I could not reproduce it with MySQL version 5.6.35. However the Drupal.org testbot reported the failing test with an newer MySQL version. Thanks again for your patch!
Please re-open this issue, if you have any objections.