-
Notifications
You must be signed in to change notification settings - Fork 111
Problem with Doctrine & Guards (not) persisting permissions #106
Comments
I'm not sure to understand. ZfcRbac never flushes or something. Your solution of cascading persist is indeed the right one. |
That is true, ZfcRbac doesn't flush, but my UserManager does. Maybe I have to elaborate this a little bit more:
In my eyes it would be unwise to persist the new permission as it is only needed by the guards and therefore shouldn't be written to the database. Using 'cascade=(persist)' would solve the Exception but it would also (possibly) create many new permission in the database. Changing the guards configuration could in result lead to unexpected behaviour:
It would however be possible, that |
Haa I see the problem... Nice finding! Actually, those permissions are just added internally to take advantage of the fact that roles have inheritance. But those permissions have no real meaning. I will try to find a fix to that. Thanks! |
Sure, no problem! I'd suggest to use an |
Hhmm. can you try to provide a fix? :) |
Ah I understand now how it is supposed to work. The only thing I could think of, was to deprecate AbstractGuard::isAllowed()
And to adjust
Not sure if thats the way to go tho. And please excuse the CRAP in |
Got it, that's probably better:
|
Looks good to me. Can you make a PR please ? :) |
@arekkas could you please share your entities Role and Permission ? |
Hm? This issue is already closed :) |
Yes I know that. But as you managed to create entities that are working with ZfcRbac 1.0 and those provided here in datas/ aren't usable, I thought it would be a great idea to share these entities. |
Why aren't they valid? What error do you have? Envoyé de mon iPhone
|
When trying to update an user, I get: "A new entity was found through the relationship 'User\Entity\Role#permissions' that was not configured to cascade persist operations for entity: controller.user\controller\usercontroller.settings. To solve this issue: Either explicitly call EntityManager#persist() on this unknown entity or configure cascade persist this association in the mapping for example @manytoone(..,cascade={"persist"})."
Obviously, the
User
has a m:n relation toRole
and Role has a m:n relation toPermission
. The Controller throwing the exception isUser\Controller\UserController::settingsAction()
.My zfcrbac config looks like this:
Role:addPermission:
The problem originates in
ControllerGuard::isGranted()
/RouteGuard::isGranted()
I am unsure if this is expected behaviour (guards persisting permissions) but it doesn't seem to me that way.
The text was updated successfully, but these errors were encountered: