You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A serialized object in PHP that has null values before and after private fields like will fail to serialize because Postgres PDO serialization will stop on null values.
Example: "O:1:"A":1:{s:8:"\0A\0field";N;}"
A terminating zero byte is not required, and should not be counted in length. (If a terminating zero byte is found before length bytes are processed, PQescapeStringConn stops at the zero; the behavior is thus rather like strncpy.)
Therefore, if we need to store a serialized object into a text Postgres column, it will fail.
Laravel uses serialization for job_batches.options and when used with PostgresSQL causes this error:
I would be fine with that solution as long as we can do it in a backwards compatible way for other database drivers. Or, ideally, not base64_encode at all when using other drivers.
Description:
A serialized object in PHP that has null values before and after private fields like will fail to serialize because Postgres PDO serialization will stop on null values.
Example:
"O:1:"A":1:{s:8:"\0A\0field";N;}"
This is because of PQescapeStringConn
Therefore, if we need to store a serialized object into a text Postgres column, it will fail.
Laravel uses serialization for
job_batches.options
and when used with PostgresSQL causes this error:Steps To Reproduce:
Possible Fix
We can use base64_encode before inserting & base64_decode after fetching the serialized objects.
If you find this solution ok let me know and I'll create a PR for it.
Thank you.
References:
PostgreSQL: Chapter 33. libpq — C Library
Text column type doesn't reliably hold serialized variables
The text was updated successfully, but these errors were encountered: