Skip to content

[Cache] Stop defaulting to igbinary in DefaultMarshaller #57702

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

Merged
merged 1 commit into from
Jul 25, 2024

Conversation

martijnc
Copy link

@martijnc martijnc commented Jul 10, 2024

Q A
Branch? 7.2
Bug fix? yes
New feature? no
Deprecations? no
Issues Fix #52391
License MIT

igbinary used to be a drop in replacement for PHP's serialize but recent changes (in PHP 7.4) to the handling of uninitialized properties in serialize have not made it into igbinary, so it no longer is a simple drop in replacement.

This only removes igbinary as the default serializer, code can still opt-in through the first constructor argument.

This may result in a performance regression on systems with igbinary as it would no longer be used by default.

Fixes #52391

@carsonbot
Copy link

Hey!

I see that this is your first PR. That is great! Welcome!

Symfony has a contribution guide which I suggest you to read.

In short:

  • Always add tests
  • Keep backward compatibility (see https://symfony.com/bc).
  • Bug fixes must be submitted against the lowest maintained branch where they apply (see https://symfony.com/releases)
  • Features and deprecations must be submitted against the 7.2 branch.

Review the GitHub status checks of your pull request and try to solve the reported issues. If some tests are failing, try to see if they are failing because of this change.

When two Symfony core team members approve this change, it will be merged and you will become an official Symfony contributor!
If this PR is merged in a lower version branch, it will be merged up to all maintained branches within a few days.

I am going to sit back now and wait for the reviews.

Cheers!

Carsonbot

@carsonbot carsonbot added this to the 7.2 milestone Jul 10, 2024
@carsonbot

This comment was marked as resolved.

@martijnc martijnc changed the base branch from 7.2 to 5.4 July 10, 2024 19:40
@derrabus
Copy link
Member

Changing the default behavior silently in a bugfix release on an LTS branch sounds like a bad idea, tbh.

If we want to do this, we should target 7.2 and deprecate not setting this option first.

@martijnc martijnc changed the base branch from 5.4 to 7.2 July 10, 2024 20:23
@nicolas-grekas
Copy link
Member

The code is able to auto-detect if igbinary was used when serializing so that payloads are compatible with either flags (if igbinary is installed).
This means changing the default behavior is fine without further precautions.
We could even do this on 5.4 if we think the state of igbinary is too bad.

@OskarStark OskarStark changed the title [Cache] Stop defaulting to igbinary in DefaultMarshaller [Cache] Stop defaulting to igbinary in DefaultMarshaller Jul 15, 2024
@xabbuh
Copy link
Member

xabbuh commented Jul 17, 2024

This means changing the default behavior is fine without further precautions.

I am not convinced that this is always true. What if other PHP projects not using Symfony read the serialised data? They may not have the same mechanism to detect if igbinary was used.

@nicolas-grekas
Copy link
Member

What if other PHP projects not using Symfony read the serialised data? They may not have the same mechanism to detect if igbinary was used.

This would be an unsupported use case. Cached items are certainly not meant for interop. We already changed their format without caring in the past.

This change is desired to me.

Copy link
Member

@nicolas-grekas nicolas-grekas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works for me on 7.2. I'd also be fine on 5.4/6.4: igbinary is not safe anymore, ppl are at risk when using it, and the fact that it's not opt-in when the extension is installed adds to the risk.

@nicolas-grekas
Copy link
Member

See eg comments in igbinary/igbinary#273

Copy link
Member

@chalasr chalasr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 for 5.4

@derrabus
Copy link
Member

Works for me on 7.2.

I think, 7.2 is the compromise we can all settle on. And please let's add a remark to the upgrade guide for 7.2 and the Cache component's change log.

I'd also be fine on 5.4/6.4: igbinary is not safe anymore, ppl are at risk when using it, and the fact that it's not opt-in when the extension is installed adds to the risk.

I understand that and maybe it was even a mistake to enable igbinary serialization automatically. But I believe that there are enough projects out there that don't hit those issues and still rely on the performance gain they get from leveraging igbinary. Maybe I'm too conservative here, but I wouldn't want to lure those apps into a performance degradation with an innocent bugfix release.

igbinary used to be a drop in replacement for PHP's `serialize` but recent changes (in PHP 7.4) to the handling of uninitialized properties in `serialize` have not made it into igbinary, so it no longer is a simple drop in replacement.

This only removes igbinary as the default serializer, code can still opt-in through the first constructor argument.

This may result in a performance regression on systems with igbinary as it would no longer be used by default.
@fabpot
Copy link
Member

fabpot commented Jul 25, 2024

Thank you @martijnc.

@fabpot fabpot merged commit 0d879fc into symfony:7.2 Jul 25, 2024
10 checks passed
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.

[Cache] igbinary_serialize is not compatible with serialize anymore
7 participants