Problem/Motivation
I'm getting ahead of myself with this, but I came across one likely incompatibility with Drupal 9.2.x branch on PHP 8.1:
In PHP 8.1, using the Serializable interface will result in a PHP deprecation notice. Drupal has one such hit.
Steps to reproduce
Run Drupal 9 on PHP 8.1/nightly builds.
Proposed resolution
Implement the PHP 7.4 `__unserialize` and `__serialize` methods in addition to the `serialize` and `unserialize` from the interface.
Remaining tasks
Implement the PHP 7.4 `__unserialize` and `__serialize` methods in addition to the `serialize` and `unserialize` from the interface.
User interface changes
None.
API changes
None.
Data model changes
The serialized format/string might be different, although I suspect this is an unlikely scenario.
Release notes snippet
Todo.
Comment | File | Size | Author |
---|---|---|---|
#13 | 3212021-13.patch | 1.55 KB | andypost |
#13 | interdiff.txt | 728 bytes | andypost |
Comments
Comment #2
andypostComment #3
andypostComment #4
andypostThere's more usages
Comment #5
andypostComment #6
catchComment #7
andypostGuess kinda it, but
?string
(from serialize) vsarray
from interfaceComment #8
andypostfixed version https://wiki.php.net/rfc/custom_object_serialization
Comment #10
andypostNew method does not needs
unserialize()
Comment #11
daffie CreditAttribution: daffie commentedMaybe a stupid question, but did you not do
return serialize($this->__serialize());
?Why do we do here the same as the method
__unserialize()
? Can we call that method instead to do the work?Why does the method
unserialize()
returns $this? I get that we cannot remove this, because it will be a BC break. Just strange to me.Comment #12
heni_deepak CreditAttribution: heni_deepak commentedPlease review the error I have added in the screenshot.
Comment #13
andypostThank you, fixed
Comment #14
daffie CreditAttribution: daffie commentedAll code changes look good to me.
It fixes the problem from the IS.
I could not find any other classes that implement
\Serializable
in core.For me it is RTBC.
Comment #15
catchCommitted 4d2631d and pushed to 9.3.x. Thanks!
Comment #17
catch