File tree Expand file tree Collapse file tree 1 file changed +38
-0
lines changed
Expand file tree Collapse file tree 1 file changed +38
-0
lines changed Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace Sandstorm \NeosAcl \Performance ;
4+
5+ use Neos \Flow \Aop \JoinPointInterface ;
6+ use Neos \Flow \Annotations as Flow ;
7+
8+ /**
9+ * the NodePrivilegeContext does not cache the Node references;
10+ * but instead fetches them again and again (for every node
11+ * check) from the DB.
12+ *
13+ * This is a hotfix, which adds the cache in an aspect.
14+ *
15+ * @Flow\Scope("singleton")
16+ * @Flow\Aspect
17+ */
18+ class NodeContextPerformanceAspect
19+ {
20+
21+ protected $ nodeCache = [];
22+
23+ /**
24+ * @Flow\Around("method(Neos\ContentRepository\Security\Authorization\Privilege\Node\NodePrivilegeContext->getNodeByIdentifier())")
25+ * @return void
26+ */
27+ public function boot (JoinPointInterface $ joinPoint )
28+ {
29+ $ nodeIdentifier = $ joinPoint ->getMethodArgument ('nodeIdentifier ' );
30+ if (array_key_exists ($ nodeIdentifier , $ this ->nodeCache )) {
31+ return $ this ->nodeCache [$ nodeIdentifier ];
32+ }
33+
34+ $ result = $ joinPoint ->getAdviceChain ()->proceed ($ joinPoint );
35+ $ this ->nodeCache [$ nodeIdentifier ] = $ result ;
36+ return $ result ;
37+ }
38+ }
You can’t perform that action at this time.
0 commit comments