Needs review
Project:
Entity reference
Version:
7.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
5 Sep 2014 at 09:50 UTC
Updated:
24 Aug 2017 at 12:22 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
chaby commentedComment #2
SebCorbin commentedHmm, this could hack the behavior of other modules, i.e. if any
hook_entityreference_prepare_view_access_alter()is implemented, modules relying on entity_access aka the old way,hook_entity_access/hook_node_accesswill not be called.Thus, I would let the default behavior as it is, and add the
drupal_alter()after so that we can override$itemsComment #3
chaby commentedIndeed you are right but it was intented as explain in the issue summary :
However, bypassing other modules behaviours is indeed not a good idea and furthermore, the hook name is not correct (by design, an alter means you change data previously set, not an alternative)..
If it would be a real hook alter (so called after default behaviour), we cannot implement hook_node_access() for full view node page in our use case (and did'nt find another way to achieve it).
Anyway, keep in mind that if other modules make some queries for view op in entity_access, return false and user has update access, it would execute X references queries for nothing...
Comment #4
chaby commentedTake an another approach : use a pre-filtered query with tag to let's other modules remove referenced entities where access should be denied.
Allowed references would be still called with entity_access() but the implemented hooks such as node_access() could play with ugly static cache to check that access was previously allowed (i.e not excluded) and prevent redundant check for performance.
Comment #5
chaby commentedComment #6
Solthun commentedI tried the latest approach, but ran into the problem of not making anydifference when the actual query tag alter was removing each referenced item.
Added a small change to solve this.
Comment #7
Solthun commentedRe-rolled this lonely patch.