Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Encrypted fields are constantly being persisted to the Database even when they aren't being modified. #24

Open
jayesbe opened this issue Jan 19, 2017 · 9 comments

Comments

@jayesbe
Copy link

jayesbe commented Jan 19, 2017

Anytime I perform an $em->flush(); An Entity that was loaded which contains encrypted fields will show up as an UPDATE statement in the log. There are no changes to the entity. The fields aren't even used. The UPDATE should not occur.

Aside from this, My understanding of the code is that the values are decrypted as soon as the entity is loaded.. shouldn't they only be decrypted when some encrypted field is retrieved from the Entity ?

@jayesbe
Copy link
Author

jayesbe commented Jan 19, 2017

Looks like someone fixed this

bouke-nederstigt@3c1255b

@numediaweb
Copy link

@jayesbe
Is this still an issue? or is it already fixed/merged?

@jayesbe
Copy link
Author

jayesbe commented Jun 6, 2018

@numediaweb ive moved on to a fork of this project. https://github.com/michaeldegroot/DoctrineEncryptBundle

@Henridv
Copy link

Henridv commented May 31, 2019

Looks like someone fixed this

bouke-nederstigt@3c1255b

This change doesn't fix this issue.

From what I see the fork also doesn't fix this? @jayesbe

@jayesbe
Copy link
Author

jayesbe commented May 31, 2019

@Henridv I am using the degroot fork however I do have a fork of my own with the fix merged.

absolute-quantum/DoctrineEncryptBundle@master...Indinuity:degroot

@Henridv
Copy link

Henridv commented Jun 4, 2019

@jayesbe
Thanks!

However, your fix only reduces the encrypt/decrypt operations. All entities with encrypted properties fetched from the database will be marked as 'dirty' in the entity manager.
As such, every flush() will cause all entities to be written back to the database.

@jayesbe
Copy link
Author

jayesbe commented Jun 8, 2019

@Henridv interesting.. What happens if you flush() only the entities you are modifying?

I don't know when I'll have time to look into it.. if you get a chance to look into it further or come across a better fix let me know.

@jriboux
Copy link

jriboux commented Jan 27, 2020

@jayesbe, @Henridv I think I found a workaround using the "deferred explicit" tracking policy (See doctrine documentation).

Setting deffered explicit tracking policy to all entities containing encrypted fields will prevent them from being automatically persisted on flush. They will be persisted only if persist() is explicitely called on each instance you want to save in DB.

@jayesbe
Copy link
Author

jayesbe commented Jan 28, 2020

@jriboux are you working on an PR ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants