Skip to content

Drop more usages of Serializable #30286

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
Mar 4, 2019

Conversation

nicolas-grekas
Copy link
Member

@nicolas-grekas nicolas-grekas commented Feb 18, 2019

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

When the serialized payload of some class is used for ephemeral needs, my proposal here is to drop implementing Serializable and provide a deprecation layer based on __sleep to still call the serialize/unserialize methods. This means that at the behavior level, we provide BC, and at the payload level, we don't.

That leaves us with only two "not ephemeral" use cases:

  • Route and CompilerRoute instances are serialized by Drupal. We'd better not break such existing payloads without being sure it's ok for Drupal (ping @alexpott). My proposal in this PR is to schedule the BC break for Symfony 5, and ask Drupal (and others) to add a check in their unserialization logic so that they are able to recompile the cached list of routes if unserialize fails due to this change. They could alternatively implement Serializable on their own, without calling parent::(un)serialize().
  • TokenInterface from Security - for this one, I have no idea yet, except either plan for breaking BC at the payload level (which would mean invalidating all sessions when moving to SF5) - or create a new interface if we think breaking sessions is not reasonable. For now, I've kept using Serializable, which could be also fine keeping if we mark the corresponding method final to force

WDYT?

@OskarStark
Copy link
Contributor

Typo:
This leaves us WITH....

@alexpott
Copy link
Contributor

Drupal extends CompilerRoute and overrides both ::serialize and ::unserialize. We can rebuild our router so the change to the payload should be okay.

@nicolas-grekas
Copy link
Member Author

@alexpott thanks, then the plan for Drupal should be to stop calling parent::serialize()/unserialize() asap and explicitly declare implements \Serializable. Then you'd preserve full forward and backward compat.

@nicolas-grekas nicolas-grekas force-pushed the drop-more-serializable branch 3 times, most recently from 37674f1 to 66b50bf Compare February 20, 2019 08:39
Copy link
Member

@fabpot fabpot left a comment

Choose a reason for hiding this comment

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

I would remove the possibility to serialize a Kernel as I don't see (anymore) the use cases.

@nicolas-grekas nicolas-grekas force-pushed the drop-more-serializable branch 3 times, most recently from 966d44a to 856ae9f Compare February 23, 2019 16:48
@nicolas-grekas
Copy link
Member Author

I would remove the possibility to serialize a Kernel as I don't see (anymore) the use cases.

Actually, that's not possible: the kernel is serialized in FrameworkBundle for insulated tests, see

$kernel = var_export(serialize($this->kernel), true);

@nicolas-grekas nicolas-grekas force-pushed the drop-more-serializable branch from 856ae9f to 05d6475 Compare March 4, 2019 08:45
@fabpot
Copy link
Member

fabpot commented Mar 4, 2019

Thank you @nicolas-grekas.

@fabpot fabpot merged commit 05d6475 into symfony:master Mar 4, 2019
fabpot added a commit that referenced this pull request Mar 4, 2019
This PR was merged into the 4.3-dev branch.

Discussion
----------

Drop more usages of Serializable

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

When the serialized payload of some class is used for ephemeral needs, my proposal here is to drop implementing `Serializable` and provide a deprecation layer based on `__sleep` to still call the `serialize`/`unserialize` methods. This means that at the behavior level, we provide BC, and at the payload level, we don't.

That leaves us with only two "not ephemeral" use cases:
- `Route` and `CompilerRoute` instances are serialized by Drupal. We'd better not break such existing payloads without being sure it's ok for Drupal (ping @alexpott). My proposal in this PR is to schedule the BC break for Symfony 5, and ask Drupal (and others) to add a check in their unserialization logic so that they are able to recompile the cached list of routes if unserialize fails due to this change. They could alternatively implement `Serializable` on their own, without calling `parent::(un)serialize()`.
- `TokenInterface` from `Security` - for this one, I have no idea yet, except either plan for breaking BC at the payload level (which would mean invalidating all sessions when moving to SF5) - or create a new interface if we think breaking sessions is not reasonable. For now, I've kept using `Serializable`, which could be also fine keeping if we mark the corresponding method `final` to force

WDYT?

Commits
-------

05d6475 Drop more usages of Serializable
@nicolas-grekas nicolas-grekas deleted the drop-more-serializable branch March 4, 2019 10:52
@nicolas-grekas nicolas-grekas modified the milestones: next, 4.3 Apr 30, 2019
@fabpot fabpot mentioned this pull request May 9, 2019
@Tobion
Copy link
Contributor

Tobion commented Jun 5, 2019

@alexpott FYI #31866

Tobion added a commit that referenced this pull request Jun 5, 2019
…(Tobion)

This PR was merged into the 4.3 branch.

Discussion
----------

[Routing] revert deprecation of Serializable in routing

| Q             | A
| ------------- | ---
| Branch?       | 4.3
| Bug fix?      | no
| New feature?  | no <!-- please update src/**/CHANGELOG.md files -->
| BC breaks?    | no     <!-- see https://symfony.com/bc -->
| Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files -->
| Tests pass?   | yes    <!-- please add some, will be required by reviewers -->
| Fixed tickets |
| License       | MIT
| Doc PR        |

we still need to implement Serializable as long as we support PHP < 7.4. otherwise serialized data in php 7.2 would not work anymore when people upgrade to php 7.4. see discussion in #31792 (comment)
partly reverts #30286

Commits
-------

d32a295 [Routing] revert deprecation of Serializable in routing
nicolas-grekas added a commit that referenced this pull request Jun 5, 2019
This PR was merged into the 5.0-dev branch.

Discussion
----------

[Routing] remove deprecations

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | no
| New feature?  | no <!-- please update src/**/CHANGELOG.md files -->
| BC breaks?    | yes     <!-- see https://symfony.com/bc -->
| Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files -->
| Tests pass?   | yes    <!-- please add some, will be required by reviewers -->
| Fixed tickets |
| License       | MIT
| Doc PR        |

Ref. #30249, #30286, #24894

Commits
-------

5beb5f8 [Routing] remove deprecations
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.

8 participants