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

Skip to content

[Routing] remove deprecations #31792

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
Jun 5, 2019

Conversation

Tobion
Copy link
Contributor

@Tobion Tobion commented Jun 2, 2019

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

Ref. #30249, #30286, #24894

/**
* @internal since Symfony 4.3, will be removed in Symfony 5 as the class won't implement Serializable anymore
*/
public function serialize()
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@nicolas-grekas removing this but keeping the new magic serialization methods means that the deserialization breaks when upgrading php to 7.4. so persisted routes will not work anymore when upgrading php. I think that was one of the main reasons why we implemented Serializable in the first place.

Copy link
Member

Choose a reason for hiding this comment

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

So, we can keep them for a smoother transition, and keep only @internal then, would that be ok to you?

Copy link
Member

Choose a reason for hiding this comment

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

Oh, let's make them really final to close this a bit more?

Copy link
Contributor Author

@Tobion Tobion Jun 4, 2019

Choose a reason for hiding this comment

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

If we make them final Drupal can't overwrite them anymore which is what they do in https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21Routing%21CompiledRoute.php/class/CompiledRoute/8.2.x
I don't see what else they could do then. It would make it impossible to adjust serialization in a subclass.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@nikic In https://wiki.php.net/rfc/custom_object_serialization you say

For this reason, code using parent::serialize() is generally broken

But from what I see the implementation in Drupal calling parent::serialize does not seem broken

public function serialize() {
    $data = unserialize(parent::serialize());
    $data['fit'] = $this->fit;
    $data['patternOutline'] = $this->patternOutline;
    $data['numParts'] = $this->numParts;
    return serialize($data);
  }
  public function unserialize($serialized) {
    parent::unserialize($serialized);
    $data = unserialize($serialized);
    $this->fit = $data['fit'];
    $this->patternOutline = $data['patternOutline'];
    $this->numParts = $data['numParts'];
  }

It's not using backreferences but if it was, this approach using unserialize(parent::serialize() seems fine.

Copy link
Contributor Author

@Tobion Tobion Jun 4, 2019

Choose a reason for hiding this comment

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

As long as we need to support php version < 7.4, don't don't see a solution without \Serializable. So I would propose to revert #30286 for the routing component.

Copy link
Member

Choose a reason for hiding this comment

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

We provide __serialize and __unserialize as extension points. Note that yes, routes are exposed to the issue. The reason is that options/defaults can be anything, like objects with these references that break. Drupal is doing that (objects there).

This means to me we should keep implementing Serializable, but make the corresponding method @internal - and tell ppl to use __serialize and __unserialize as extension points instead.

This will provide FC/BC.

@Tobion Tobion force-pushed the remove-router-deprecations branch from c1a8344 to a1ce27c Compare June 2, 2019 05:02
@nicolas-grekas nicolas-grekas added this to the 5.0 milestone Jun 2, 2019
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
@Tobion Tobion force-pushed the remove-router-deprecations branch from a1ce27c to c7dc368 Compare June 5, 2019 11:40
@Tobion Tobion force-pushed the remove-router-deprecations branch from c7dc368 to 5beb5f8 Compare June 5, 2019 11:42
@Tobion
Copy link
Contributor Author

Tobion commented Jun 5, 2019

Rebased and ready

@nicolas-grekas
Copy link
Member

Thank you @Tobion.

@nicolas-grekas nicolas-grekas merged commit 5beb5f8 into symfony:master Jun 5, 2019
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
@Tobion Tobion deleted the remove-router-deprecations branch June 5, 2019 14:51
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 dead fixtures

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

Follows #31792

Commits
-------

181aa02 [Routing] remove dead fixtures
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