Closed lekoala closed 3 years ago
I'm wondering if this is the desired behavior, because having null values in array doesn't seem that strange.
It is, because Binary::safeSubstr()
is a separate library that has no concept of arrays or databases and only deals with strictly typed strings.
That being said, making EncryptedRow
handle NULLs more gracefully is worth fixing at the CipherSweet level.
;-) wow that was fast
Just ran into this minor issue
I'm passing an array from the database. It contains null values, something like
Array ( [ID] => 3 [Name] => demo3 [MyText] => (null) )
Using the row rotator, I get this error
TypeError: Argument 1 passed to ParagonIE\ConstantTime\Binary::safeSubstr() must be of the type string, null given, called in \vendor\paragonie\ciphersweet\src\Backend\BoringCrypto.php on line 108
\vendor\paragonie\constant_time_encoding\src\Binary.php:67 \vendor\paragonie\ciphersweet\src\Backend\BoringCrypto.php:108 \vendor\paragonie\ciphersweet\src\EncryptedRow.php:342 \vendor\paragonie\ciphersweet\src\KeyRotation\RowRotator.php:44
I'm wondering if this is the desired behavior, because having null values in array doesn't seem that strange. I fixed the issue in the meantime by replacing nulls by empty strings. Either safeSubstr could accept nulls and treat them as empty strings, or maybe a note should be added somewhere in the docs