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

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -