Closed (won't fix)
Project:
Drupal core
Version:
7.x-dev
Component:
taxonomy.module
Priority:
Major
Category:
Task
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
25 Aug 2013 at 14:50 UTC
Updated:
19 May 2016 at 01:16 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
agentrickardLet's see what tests this breaks...
Comment #2
xjmThis will break TAC. Period. :)
Comment #3
xjmAlso this is a BC break generally; I don't understand what the point of this patch against 7.x is?
Comment #4
xjmI'd like to mark this wontfix unless there's an actual manifest bug here.
Comment #5
agentrickardThe bug is that the behavior is categorically wrong. No other _load() function or method enforces access controls. Access controls are determined based on the results of a load(). The reason that tests don't fail is that core doesn't use this feature.
The bug did manifest in contrib, when someone tried to use taxonomy_term_load_multiple() as part of an autocomplete. #2072661: PDOException: SQLSTATE[42S22]: Column not found: 1054 Unknown column t.tid in where clause
I don't see where this breaks TAC, which only calls taxonomy_term_load_multiple() within _taxonomy_access_autocomplete_validate().
Note also that the core taxonomy_autocomplete doesn't use this method. It uses a proper db_select(), which reinforces that the logic here is wrong.
Should we won't fix this for 7? Maybe. This has been fixed in D8, and we may simply be saying that it's too late to fix this bug. The purist in me does not like that answer.
Comment #6
agentrickardPerhaps a better reason to not fix this is that I would call a similar logic error in taxonomy_get_parents(), taxonomy_get_children() and taxonomy_get_tree(), which all tag for access control filtering.
Those are lookup functions that would be better served by attaching #access data the way that the menu system does.
Comment #7
agentrickardThose three functions are still present in D8, so that discussion should be had.
Here's why this logic is wrong.
taxonomy_get_tree"[Returns] an array of all term objects in the tree."taxonomy_term_load_parents"[Returns] an array of term objects which are the parents of the term $tid."taxonomy_term_load_children"[Returns] an array of term objects that are the children of the term $tid."But that is not what these functions do. They return all elements (tree, parents, children) that the current request has permission to access. Now, if these were functions for display, that would be fine. But these are internal API calls. Simple loaders. Loaders should do one thing: load.
These documentations of the API are all incorrect. The expectation should be to return _all_ items, with flags for access for the current request.
Either that or the documentation of the API should change.
The reason this has persisted for so long is that nothing in core actually uses
hook_query_term_access_alter().Comment #8
agentrickardCurious to see if any core tests break when we remove that logic.
Comment #9
agentrickardAaaand I think that proves my point.
Comment #10
berdirNo, it doesn't ;) That there is no test coverage of term_access doesn't mean that it can be removed, see #1947270: Add test coverage for the term_access query tag.
Yes, the term_access in buildQuery() was removed because that was incorrect. The issue above was opened as a follow-up when we removed it from there.
Those other methods aren't simple loader functions that load based on id's. They're query + load, so they have to respect term_access. There is no other way to apply access control for those. If other places don't, then that needs to be fixed.
Comment #11
agentrickardSo there is no API for getting term parents consistently? Or the tree? That result will always be variable based on access control?
That strikes me as a very large bug and it suggests, at the least, that we need two separate functions: one to apply access filtering and one that does not.
In the rest of core entities, the burden of access is on the caller to these type of loading functions. Compare (yes, it's deprecated) node_load_multiple().
My point is that this is horrible DX and should be fixed. Taxonomy can't be the one odd case here. We should have a consistent API.
Comment #12
agentrickardIt's a shame I didn't find this issue until now, and I'm about to go on vacation (offline) for two weeks.
One further bit of piling on here before then: The term_access query flag doesn't have an operation assigned to it, which means that the query alter system will assume "view" (or, in reality, that all alters are the same for all conditions).
I don't think that works in the use-case I have for taxonomy access, in which users are restricted in what terms they can assign to nodes, but not restricted in any other sense.
Comment #13
xjm8: drupal-2073663-taxonomy-term-load-8.patch queued for re-testing.
Comment #15
a_thakur commentedComment #16
mgiffordJust unassigning issues that haven't been developed for a bit in the D8 queue.
Comment #17
aditya.ghan commentedI had a discussion with @xjm regarding this task.
I believe this is not a bug, but rather a new task. Indeed, the taxonomy load functions in Drupal 8 (Version 8.0.x - development) use the term access tag when loading terms. Given below is one example of such a load function. Hence, changing the type of this issue to task.
Comment #18
xjmThanks @aditya.ghan!
(Updating issue credit for the major triage and adding the relevant tags, since we've verified the issue does still exist.)
Comment #19
catchThis needs a major issue summary update, since the issue has been completely inverted from taxonomy_term_load() checking access in 6.x or 7.x (which should never have been the case), to taxonomy_get_tree() checking it (which has to be the case, but I can see a use case for getting the full tree in API calls without access checking).
Just updating the title for now.
Comment #21
xjmI've confirmed that the tag is added for
loadParents(),loadChildren(),loadTree(), andgetNodeTerms()in D8, as well as on the relevant Views plugins, but not for loading taxonomy terms themselves.Based on the fact that this cannot be backported in a BC way, and that it has been fixed in D8, I'm actually going to mark this wontfix against D7. If we want a followup for what @catch describes we can do that in another issue I think, since the current summary is confusingly out of date. Tagging for that, just in case.