Skip to content

Commit

Permalink
Merge pull request #12 from cleverage/bugfix/handle-null-string
Browse files Browse the repository at this point in the history
Fix a bug when saving null instead of a string
  • Loading branch information
johnkrovitch authored Dec 8, 2020
2 parents af43afd + 21f1bf0 commit 6e2f065
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@
"Sidus\\EncryptionBundle\\": "src/"
},
"exclude-from-classmap": [
"/Tests/"
"/Tests/",
"/tests/"
]
},
"autoload-dev": {
Expand Down
6 changes: 6 additions & 0 deletions src/Doctrine/Type/Behavior/EncryptType.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ trait EncryptType

public function convertToPHPValue($value, AbstractPlatform $platform): string
{
if ($value === null) {
$value = '';
}
// Decode value previously encoded in base64 for database storage
$value = base64_decode($value);

Expand All @@ -19,6 +22,9 @@ public function convertToPHPValue($value, AbstractPlatform $platform): string

public function convertToDatabaseValue($value, AbstractPlatform $platform): string
{
if ($value === null) {
$value = '';
}
$value = $this->valueEncrypter->encrypt($value);

// Encoding to base64 to avoid issue when storing binary strings
Expand Down

0 comments on commit 6e2f065

Please sign in to comment.