Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[Messenger] Wrapping the PhpSerializer data in json_encode to avoid null bytes #30836

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed

Conversation

weaverryan
Copy link
Member

Q A
Branch? master
Bug fix? no
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets none
License MIT
Doc PR not needed

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!

@nicolas-grekas
Copy link
Member

That'll fail on non-UTF8 data, which can happen very quickly...

@weaverryan
Copy link
Member Author

Dang, you're right. Such a shame. Ok, closing.

@weaverryan weaverryan closed this Apr 2, 2019
@weaverryan weaverryan deleted the php-serialize-with-json branch April 2, 2019 17:11
@nicolas-grekas nicolas-grekas modified the milestones: next, 4.3 Apr 30, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants