Closed (fixed)
Project:
Permissions by Term
Version:
8.x-2.12
Component:
Code
Priority:
Major
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
28 Oct 2019 at 01:31 UTC
Updated:
10 Jan 2020 at 12:09 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
tetranz commentedComment #3
revathi.b commentedHi Ross Keatinge,
The above issue its a cache issue. If you clear cache it will resolved.
Comment #4
tetranz commentedThanks but this doesn't look like a cache issue. Clearing cache does not fix it.
Drupal\permissions_by_entity\EventSubscriber\PermissionsByEntityKernelEventSubscriber::onKernelRequest is called repeatedly. I can see that the caching mechanism is designed to prevent infinite recursion but it has a problem.
I haven't traced through all the logic but line 107 adds it to the cache
$this->checkedEntityCache->add($entity);Line 111 clears the cache again when it calls $this->accessChecker->isAccessControlled($entity).
->isChecked returns false again next time and the loop continues.
I'm not sure why the event is dispatched again after the AccessDeniedHttpException is thrown. More debugging needed.
Comment #5
tetranz commentedAnswering my question above.
I think the reason why PermissionsByEntityKernelEventSubscriber::onKernelRequest is called repeatedly is because it has already been handled by permissions_by_term.
I'm a little confused by the interaction between permissions_by_node and permissions_by_entity but if I'm understanding this correctly, if I am accessing a node controlled by permissions_by_term, do we want permissions_by_entity to be involved at all?
I think what's happening is that access to the node is denied by permissions_by_term, that throws an AccessDeniedHttpException. permissions_by_entity then gets involved and throws another AccessDeniedHttpException. Each one dispatches the KernelRequest event which causes permissions_by_entity to throw another AccessDeniedHttpException and then loop continues.
I want to use permissions_by_term to control access to nodes and permissions_by_entity to control access to media entities. That seems like the intended use-case but it seems odd that permissions_by_entity gets involved for a node after permissions_by_term has already denied access to the node.
Maybe I'm misunderstanding how this is supposed to work.
Comment #6
wellsAlso seeing this issue on 8.7.10. Appears to have been introduced by changes in PbyT 8.x-2.11, as reverting to 8.x-2.10 resolves the issue.
Comment #7
wellsHere is example full backtrace of the error happening (slightly different than the original report) --
It seems that PbyT is attempting to do something during the serving of the 403 page that triggers serving another 403 page, and so on until the nesting level error.
Comment #8
wellsNot 100% sure this is the solution needed, but if the
PermissionsByEntityKernelEventSubscriberevent subscriber is modified to only evaluate permissions on the master request, the issue does not occur and permissions seem to still be enforced correctly.Comment #9
wellsComment #10
mikemiles86I have run into this same issue. I was not able to apply the patch from #8 using composer, due to the patch diff scope being within the sub-module permssion_by_entity.
After re-rolling the patch to reference from the permission_by_term module I am able to apply the patch and the fix works.
I've attached the re-rolled patch.
Comment #11
wellsComment #12
kris77 commentedAfter apply patch in #10 seems works fine.
Thanks @mikemiles86.
Comment #13
Kirschner commentedThanks @mikemiles86 your patch works.
This bug showed itself as Out of memory Error for us. I tried 3 hours to debug that out of memory.
Allowed memory size of *many* bytes exhausted in PermissionsByEntityKernelEventSubscriber.php line 117 the throw statement.
Comment #15
jepster_Thanks for the patch. Will be part of the next release.