[Messenger] Wrapping the PhpSerializer data in json_encode to avoid null bytes #30836
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hi!
In #30814, we decided to
base64_encode
the serialized messages to avoid null characters, which can cause issues persisting on some databases and I also think Amazon SQS does not like them **(https://docs.aws.amazon.com/AWSSimpleQueueService/latest/APIReference/API_SendMessage.html), for example.The only downside is that the messages become unreadable. I thought about that more, that's really unfortunate: if I'm using some sort of a 3rd party tool (like RabbitMQ's admin dashboard) to inspect the messages, they are fully unreadable. PHP Serialized messages are ugly, but you can absolutely understand them as a human.
This proposal is to consider using
json_encode()
instead. In both cases, it's a bit awkward: the PhpSerializer is not really a PhpSerializer, but a PhpSerialize that is then encoded again to avoid null characters. base64_encode is a really "pure" way to do this, but json_encode (which, unfortunately requires an extra "array") is a lot more readable.Cheers!