Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Account for PHP 8.5 deprecating __sleep()/__wakeup()#61407

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Closed

Conversation

@nicolas-grekas
Copy link
Member

QA
Branch?6.4
Bug fix?yes
New feature?no
Deprecations?no
Issues-
LicenseMIT

Except for final and test classes, we have to account for inheritance and for existing payloads in both directions (old apps accepting payloads from updated apps and updated apps accepting them from old apps.)

This means the fix is to mimic what the engine does currently, with all the existing quirks regarding private properties.

Don't merge unlessphp/php-src#19435 is.

@carsonbotcarsonbot added this to the6.4 milestoneAug 13, 2025
@carsonbotcarsonbot changed the titlePhp85 sleep Php85 sleepAug 13, 2025
@nicolas-grekasnicolas-grekas changed the title Php85 sleepAccount for PHP 8.5 deprecating __sleep()/__wakeup()Aug 13, 2025
@nicolas-grekasnicolas-grekasforce-pushed thephp85-sleep branch 2 times, most recently frombd46163 to0ce7a72CompareAugust 13, 2025 15:04
return ['string'];
}

publicfunction__wakeup():void
Copy link
MemberAuthor

Choose a reason for hiding this comment

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

We have to add the method so that __unserialize can call it, in case a child class defines it.
We could do a method_exists check, but that's be adding more boilerplate.

Comment on lines 80 to 111
/**
* @internal
*/
publicfunction__serialize():array
{
$data = [];
foreach ($this->__sleep()as$key) {
$data[$key] =$this->$key;
}

return$data;
}

/**
* @internal
*/
publicfunction__unserialize(array$data):void
{
foreach ($dataas$key =>$value) {
$this->$key =$value;
}

$this->__wakeup();
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Might these make more sense as a trait or two, for easier reuse?

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

this concern is cross-components - we could have one trait per component, but that'd be just garbage code...

@nicolas-grekas
Copy link
MemberAuthor

My patch doesn't work BTW, I forgot to account for mangled property names.

@nicolas-grekas
Copy link
MemberAuthor

My patch doesn't work BTW, I forgot to account for mangled property names.

fixed, more garbage code...

@nicolas-grekas
Copy link
MemberAuthor

fixed, more garbage code...

well, not so so
the updated code breaks child classes that list private properties.

This deprecation is a net loss.

@nicolas-grekas
Copy link
MemberAuthor

nicolas-grekas commentedAug 13, 2025
edited
Loading

the updated code breaks child classes that list private properties.

I found the way to fix this: closure rebinding + reflection. Not pretty at all.

@nicolas-grekasnicolas-grekasforce-pushed thephp85-sleep branch 3 times, most recently from579912b to30d0ed7CompareAugust 13, 2025 16:30
nicolas-grekas added a commit that referenced this pull requestAug 14, 2025
…n't a concern (nicolas-grekas)This PR was merged into the 7.4 branch.Discussion---------- Replace __sleep/wakeup() by __(un)serialize() when BC isn't a concern| Q             | A| ------------- | ---| Branch?       | 7.4| Bug fix?      | no| New feature?  | no| Deprecations? | no| Issues        | -| License       | MITSubset of#61407* Final classes can be moved to `__(un)serialize()` - payload compatibility is preserved* Throwing sleep/wakeup - even-though those could be considered BC breaks, I don't expect anyone overwrote them to make the corresponding classes serializableCommits-------246daf3 Replace __sleep/wakeup() by __(un)serialize() when BC isn't a concern
nicolas-grekas added a commit that referenced this pull requestAug 14, 2025
…nd data collectors and make `Profile` final (nicolas-grekas)This PR was merged into the 7.4 branch.Discussion----------[HttpKernel] Deprecate `__sleep/wakeup()` on kernels and data collectors and make `Profile` final| Q             | A| ------------- | ---| Branch?       | 7.4| Bug fix?      | no| New feature?  | yes| Deprecations? | yes| Issues        | -| License       | MITRelated to#61407FTR, I searched for code extending `Profile` on github and found none.Commits-------c54120e [HttpKernel] Deprecate `__sleep/wakeup()` on kernels and data collectors and make `Profile` final
nicolas-grekas added a commit that referenced this pull requestAug 14, 2025
…ace `__sleep/wakeup()` by `__(un)serialize()` (nicolas-grekas)This PR was merged into the 8.0 branch.Discussion----------[HttpKernel][Mime][Serializer][String][Validator] Replace `__sleep/wakeup()` by `__(un)serialize()`| Q             | A| ------------- | ---| Branch?       | 8.0| Bug fix?      | no| New feature?  | yes| Deprecations? | no| Issues        |Fix#61407| License       | MITThis gets rid of all usages of `__sleep/wakeup()` while preserving FC/BC for payloads.Commits-------2b841c1 [HttpKernel][Mime][Serializer][String][Validator] Replace `__sleep/wakeup()` by `__(un)serialize()`
@nicolas-grekas
Copy link
MemberAuthor

Symfony 8 won't use sleep/wakeup anymore, see#61424
This required adding deprecations to branch 7.4 so that child classes could know about the change.
The removed lines in#61424 are this deprecation layer. 🤮

@nicolas-grekasnicolas-grekas deleted the php85-sleep branchAugust 14, 2025 15:50
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@dunglasdunglasAwaiting requested review from dunglasdunglas is a code owner

@jderussejderusseAwaiting requested review from jderussejderusse is a code owner

@xabbuhxabbuhAwaiting requested review from xabbuhxabbuh is a code owner

@ycerutoycerutoAwaiting requested review from ycerutoyceruto is a code owner

1 more reviewer

@CrellCrellCrell left review comments

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Projects

None yet

Milestone

6.4

Development

Successfully merging this pull request may close these issues.

3 participants

@nicolas-grekas@Crell@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp