Skip to content

Conversation

@alikon
Copy link
Contributor

@alikon alikon commented Dec 29, 2021

https://php.watch/versions/8.1/serializable-deprecated

Summary of Changes

added magic method

Testing Instructions

php 8.1
on frontend do a search
check the log

Actual result BEFORE applying this Pull Request

PHP Deprecated: The Serializable interface is deprecated. Implement __serialize() and __unserialize() instead (or in addition, if support for old PHP versions is necessary)

Expected result AFTER applying this Pull Request

no more deprecation

@alikon alikon added PHP 8.x PHP 8.x deprecated issues and removed PR-4.0-dev labels Dec 29, 2021
@PhilETaylor

This comment was marked as abuse.

Comment on lines +558 to +572

/**
* Magic method used for serializing.
*/
public function __serialize()
{
}

/**
* Magic method used for unserializing.
*/
public function __unserialize($serialized)
{
}

This comment was marked as abuse.

Copy link
Member

Choose a reason for hiding this comment

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

@PhilETaylor public function __serialize(): array ... shouldn't that be public function __serialize(): string?

This comment was marked as abuse.

This comment was marked as abuse.

Copy link
Member

Choose a reason for hiding this comment

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

serialize() checks if the class has a function with the magic name __serialize(). If so, that function is executed prior to any serialization. It must construct and return an associative array of key/value pairs that represent the serialized form of the object. If no array is returned a TypeError will be thrown.

Gulp. I am confused.

This comment was marked as abuse.

This comment was marked as abuse.

@richard67
Copy link
Member

Surely this is missing the actual implementation of the these functions?

@PhilETaylor It should be enough if they call the serialize() and unserialize($serialized) methods defined a bit above, right? Or can they even be aliased somehow?

@PhilETaylor

This comment was marked as abuse.

@alikon
Copy link
Contributor Author

alikon commented Dec 29, 2021

closing in favour of #36482

@alikon alikon closed this Dec 29, 2021
@alikon alikon deleted the patch-2 branch December 29, 2021 16:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

PHP 8.x PHP 8.x deprecated issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants