Update database values with same PHP values using Doctrine type -
i using doctrine2 type encrypt database values. type converts php value internally , database value encrypting , decrypting it. works due doctrine2 types.
the encryption stored base64 encoded string. every encrypted string prefixed fixed defined prefix. means database field contains both encrypted , decrypted values (this required external requirements), recognized prefix.
my wish following:
assume have entity. want force encryption or decryption of properties of entity using doctrine. forcing database value within type stored in encrypted or decrypted form.
however, when call method entitymanager::computechangesets
, none of properties of entity marked changed. of course actual data (the php values) not changed. however, database values (are supposed to) change.
how accomplish this?
some code of doctrine type:
<?php use doctrine\dbal\types\type; class encryptedtype extends type { private static $forcedecrypt = false; // encryption stuff, encrypt () , decrypt () public function converttophpvalue($value, abstractplatform $platform) { if ($value === null) { return null; } return $this -> decrypt($value, false); } public function converttodatabasevalue($value, abstractplatform $platform) { if ($value === null) { return null; } if (self::$forcedecrypt) { return (string) $value; } return $this -> encrypt((string) $value, false); } }
i have removed unneeded code.
isn't bug?
workaround: if entity managed manager, has state state_managed
, when change state_new
, force update, can solve problem.
Comments
Post a Comment