破坏Symfony2 ACL的Doctrine 2代理类

时间:2021-08-09 00:55:44

When attempting to run findAcl() on an entity with an existing entry in the acl_classes table generated by init:acl I get an AclNotFoundException.

当试图在init:acl生成的acl_classes表中的现有条目的实体上运行findAcl()时,我得到一个AclNotFoundException。

Testing with createAcl() on the object in question before calling findAcl() shows a new record in acl_classes for a proxy class of the same type and the operation completes successfully.

在调用findAcl()之前使用createAcl()对相关对象进行测试会在acl_classes中显示相同类型的代理类的新记录,并且操作成功完成。

This seems wrong, proxies should be transparent right, or am I missing something?

这似乎是错的,代理应该是透明的,或者我错过了什么?

1 个解决方案

#1


8  

I'm am just answering this because i had a hard time to find a solution and this was the first result in google for me.

我只是回答这个问题,因为我很难找到解决方案,这是谷歌的第一个结果。

Yes, it's wrong and it's a known bug for symfony2.

是的,这是错的,这是symfony2的已知错误。

Jonathan Ingram solved this, and wrote a post about it a while ago: http://jonathaningram.com.au/2012/01/13/overriding-the-objectidentityretrievalstrategy-to-check-if-a-domain-object-is-a-doctrine-proxy/

Jonathan Ingram解决了这个问题,并在不久前写了一篇关于它的帖子:http://jonathaningram.com.au/2012/01/13/overriding-the-objectidentityretrievalstrategy-to-check-if-a-domain-object-is -a-学说代理/

He created his own object identity retrieval strategy to override the default, and registered it in the services.xml (see the post above). Actually it's a pretty simple and straightforward solution, i am a bit ashamed i didn't figured it out on my own :)

他创建了自己的对象标识检索策略来覆盖默认值,并将其注册在services.xml中(参见上面的帖子)。实际上这是一个非常简单和直接的解决方案,我有点惭愧我自己没想出来:)

In symfony2.1 it's not a problem any more, see: https://github.com/symfony/symfony/pull/3826

在symfony2.1中它不再是问题,请参阅:https://github.com/symfony/symfony/pull/3826

#1


8  

I'm am just answering this because i had a hard time to find a solution and this was the first result in google for me.

我只是回答这个问题,因为我很难找到解决方案,这是谷歌的第一个结果。

Yes, it's wrong and it's a known bug for symfony2.

是的,这是错的,这是symfony2的已知错误。

Jonathan Ingram solved this, and wrote a post about it a while ago: http://jonathaningram.com.au/2012/01/13/overriding-the-objectidentityretrievalstrategy-to-check-if-a-domain-object-is-a-doctrine-proxy/

Jonathan Ingram解决了这个问题,并在不久前写了一篇关于它的帖子:http://jonathaningram.com.au/2012/01/13/overriding-the-objectidentityretrievalstrategy-to-check-if-a-domain-object-is -a-学说代理/

He created his own object identity retrieval strategy to override the default, and registered it in the services.xml (see the post above). Actually it's a pretty simple and straightforward solution, i am a bit ashamed i didn't figured it out on my own :)

他创建了自己的对象标识检索策略来覆盖默认值,并将其注册在services.xml中(参见上面的帖子)。实际上这是一个非常简单和直接的解决方案,我有点惭愧我自己没想出来:)

In symfony2.1 it's not a problem any more, see: https://github.com/symfony/symfony/pull/3826

在symfony2.1中它不再是问题,请参阅:https://github.com/symfony/symfony/pull/3826