Skip to content

Commit 6e2f065

Browse files
authored
Merge pull request #12 from cleverage/bugfix/handle-null-string
Fix a bug when saving null instead of a string
2 parents af43afd + 21f1bf0 commit 6e2f065

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@
4545
"Sidus\\EncryptionBundle\\": "src/"
4646
},
4747
"exclude-from-classmap": [
48-
"/Tests/"
48+
"/Tests/",
49+
"/tests/"
4950
]
5051
},
5152
"autoload-dev": {

src/Doctrine/Type/Behavior/EncryptType.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ trait EncryptType
1111

1212
public function convertToPHPValue($value, AbstractPlatform $platform): string
1313
{
14+
if ($value === null) {
15+
$value = '';
16+
}
1417
// Decode value previously encoded in base64 for database storage
1518
$value = base64_decode($value);
1619

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

2023
public function convertToDatabaseValue($value, AbstractPlatform $platform): string
2124
{
25+
if ($value === null) {
26+
$value = '';
27+
}
2228
$value = $this->valueEncrypter->encrypt($value);
2329

2430
// Encoding to base64 to avoid issue when storing binary strings

0 commit comments

Comments
 (0)