Problem/Motivation
When loading terms using TermStorage::loadParents()/getChildren()/getTree() it should be easier to ignore the current user's access.
Proposed resolution
Add an optional access check parameter to these methods.
Remaining tasks
None.
User interface changes
None.
API changes
Added optional param, default behavior unchanged.
Data model changes
None.
| Comment | File | Size | Author |
|---|---|---|---|
| #30 | 2938848-30.patch | 6.74 KB | smustgrave |
| #30 | interdiff-22-30.txt | 1.54 KB | smustgrave |
| #22 | 2938848-22.patch | 6.46 KB | mohit_aghera |
Comments
Comment #2
17chances commentedInitial patch
Comment #8
jonathanshawVocabularyStorage::getTopLevelTids() has the same issue.
Comment #9
kapilv commentedHear a Rerolled patch.
Comment #11
renatog commentedPlease could you update this:
Determine usage of access check in the further storage queries.To:
Determine the usage of "access check" in the further storage queries.Comment #12
ayushmishra206 commentedMade the change suggested in #11. Please review.
Comment #13
kapilv commentedComment #15
nikitagupta commentedComment #16
catchWhy not add an optional $access_check parameter to each method (defaulting to TRUE)? Adding the property means it will still be very easy for someone to get this wrong I think. We can add optional parameters to this class within the constraints of the bc policy, shouldn't be a big problem.
Comment #17
jonathanshawComment #21
smustgrave commentedUpdating tags. The issue summary is not complete and if this is a bug it will require test cases.
Comment #22
mohit_aghera commentedBased on comment from #16, adding optional $access_check parameter.
I've included the kernel test to validate whether
taxonomy_term_access_checkquery tag is added or not.I think based on that we can identify whether access_check is added.
I haven't included interdiff considering it is different approach altogether.
Let's see how it goes 🤞
Comment #23
mohit_aghera commentedComment #25
jonathanshaw#8 can be a follow-up.
Comment #26
jonathanshawComment #27
jonathanshawComment #28
alexpottGiven this is an API addition we can only really make this change in 10.1.x. We can do this under the 1 to 1 interface to implementation rule. However, storage classes are interesting because we know that alternate DB implementations often have to implement them. Therefore I think we should go for Symfony's method of doing this... which is to do this:
on the interface but then implement it on the concrete class. That way we can given alternate implementations time to change the signature in Drupal 10 before enforcing it in Drupal 11.
I also think this should be a task - I've checked the issue comments and I've not seen any reasoning for it being a bug.
Comment #29
alexpottWe might need to disable a PHPCS rule... see \Drupal\Core\Database\StatementInterface::fetchObject for an example of where we have done something similar.
Comment #30
smustgrave commentedAddressed point in #28 and #29
Comment #31
smustgrave commentedComment #32
longwaveRe #28 I looked into contrib, and found that config_terms will indeed be broken if we change this under the 1:1 rule: it provides an alternative storage that extends ConfigEntityStorage but that implements TermStorageInterface, see https://git.drupalcode.org/project/config_terms/-/blob/8.x-1.x/src/TermS...
However, with the commented out parameter, how will we notify config_terms that it needs to change in future to accommodate this? Can the debug classloader help us here?
Comment #33
catchDebugClassloader does have some support for this:
I can't find any documentation for it though, so we'd probably need to reverse engineer from a Symfony example.
Comment #34
longwaveAh, I remember where I've seen this before: we explicitly skip this in deprecation-ignore.txt:
Comment #35
smustgrave commentedSorry dropped the ball here. So is any changes needed to the latest patch?
Comment #36
larowlanI think the next steps here @smustgrave is to confirm that the debug classloader reports this as a deprecation when running tests for config terms module.
If it doesn't we'll need to revisit why we have that entry in deprecation-ignore.txt
Comment #37
smustgrave commentedI will admit I'm not sure how to go about doing that..
Should it be moved to NW then?
Comment #39
smustgrave commentedPer #36.
I'm not sure how to do that though unfortunately.
Comment #40
partdigital commentedI've run into this issue as well while working on the Access policy contrib module
My use case:
In access policy I can define different access rules that allow me to dynamically add conditions via `hook_query_TAG_alter`
I've created a Node access policy with an access rule called "Compare node tags with tags on current user (with depth)". This allows me to restrict content by ensuring the tags on the node either match the tags on the user or are a child of one of the tags on the user.
This works fine for restricting view access. However, it does not work when I attempt to limit what tags are available in the entity reference field on the node edit form. It triggers an infinite loop.
This is because, in order to restrict taxonomy terms, I also add an access policy for those terms. This also invokes
hook_query_TAG_alter()but it also callsTermStorage::loadTree()which also callshook_query_TAG_alter()This is a contrib module so including a core patch with the contrib module is really not feasible.
So I'm left with a few options:
loadTreeBypassAccess()method. (Also not ideal).It would be great to get this in.