Open matthewvalimaki opened 11 years ago
Oops, no that will break stuff.
The issue what I'm having is with FOSUserBundle and its fos_user.registration.completed event. With the following code I will get: Field "email" is not a valid field of the entity ... in PreUpdateEventArgs.
Here's the code:
public function onRegistration(FilterUserResponseEvent $event)
{
$user = $event->getUser();
}
So the code above will result in the error mentioned above. I believe it's the order of events what cause the issue, but I am not quite sure where the actual issue is. According to the error message DoctrineEncryptSubscriber::preUpdate() tries to update a field that doesn't exist.
Any ideas?
+1 for a solution to this.
The problem seems to occour when you update a user entity more than once. Calling $this->em->detach($user);
after the first update and before the second one works for us.
+1
Hi @matthewvalimaki, what's wrong with your solution. I think it could solve the problem here.
We've encountered the same problem with multiple updates of an entity within the same request. It can render this bundle unusable on applications with complex requests. This is the same issue as #40.
The resolution proposed here for DoctrineEncryptSubscriber::preUpdate() here: https://github.com/reprovinci/doctrine-encrypt/issues/2 ...
if ($args->hasChangedField($propName)) { $args->setNewValue($propName, $this->encryptor->encrypt($args->getNewValue($propName))); }
... appears to resolve the issue.
Maybe we can fix it and create PR ?
I propose that in DoctrineEncryptSubscriber::preUpdate() we check the entityChangeSet[] for a field before trying to update the field.