rfc:phase_out_serializable

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
rfc:phase_out_serializable [2020/12/07 15:46]
nikic
rfc:phase_out_serializable [2021/04/28 14:55] (current)
nikic
Line 2: Line 2:
   * Date: 2020-12-07   * Date: 2020-12-07
   * Author: Nikita Popov <nikic@php.net>   * Author: Nikita Popov <nikic@php.net>
-  * Status: Under Discussion+  * Status: Implemented
   * Target Version: PHP 8.1   * Target Version: PHP 8.1
   * Implementation: https://github.com/php/php-src/pull/6494   * Implementation: https://github.com/php/php-src/pull/6494
Line 18: Line 18:
 A class is "only Serializable" if it is non-abstract, implements ''Serializable'', and does not implement ''%%__serialize()%%'' and ''%%__unserialize()%%''. Then: A class is "only Serializable" if it is non-abstract, implements ''Serializable'', and does not implement ''%%__serialize()%%'' and ''%%__unserialize()%%''. Then:
  
-  * In PHP 8.1, an "only Serializable" class will throw a deprecation warning. +  * In PHP 8.1, declaring an "only Serializable" class will throw a deprecation warning. Other implementations of ''Serializable'' will be accepted without a deprecation warning, because libraries supporting PHP < 7.4 will generally need to implement both the old and new mechanisms
-  * In PHP 9.0, an "only Serializable" class will generate a compile-time error. All other implementations of ''Serializable'' will result in a deprecation warning. Additionally, payloads using the ''C'' serialization format will fail to unserialize. +  * In PHP 9.0 the ''Serializable'' interface will be removed and ''unserialize()'' will reject payloads using the ''C'' serialization format. Code needing to support both PHP < 7.4 and PHP >= 9.0 may polyfill the ''Serializable'' interface, though it will have no effect on serialization.
-  * In PHP 10.0 the ''Serializable'' interface will be removed. +
- +
-The intent behind this deprecation timeline is to remove internal support for Serializable by PHP 9, but do this in a way that allows codebases to support multiple PHP versions easily, even across large ranges.+
  
 If a class implements both ''Serializable'' and ''%%__serialize()%%''/''%%__unserialize()%%'', the latter take precedence (on versions that support them), and the ''Serializable'' interface is only used to decode existing serialization payload using the obsolete ''C'' format. To migrate to the new mechanism, it's possible to either replace ''Serializable'' entirely (if support for PHP 7.3 and below is not needed) or to implement both (if it is needed). If a class implements both ''Serializable'' and ''%%__serialize()%%''/''%%__unserialize()%%'', the latter take precedence (on versions that support them), and the ''Serializable'' interface is only used to decode existing serialization payload using the obsolete ''C'' format. To migrate to the new mechanism, it's possible to either replace ''Serializable'' entirely (if support for PHP 7.3 and below is not needed) or to implement both (if it is needed).
  
-From an internal perspective, ''Serializable'' support will be gone in PHP 9.0and only a stub interface will be retained. PHP 10.0 removes that stub interface entirelyOnly at that point will it no longer be trivial to support both PHP < 7.4 and >= 10.0which should be a more than sufficient grace period.+An earlier version of this RFC proposed an additional step: PHP 9.0 would deprecate all uses of Serializable (including those that are not "only Serializable"and only remove the interface in PHP 10.0. Howeverthis approach was deemed too complicated.
  
 ==== PDO::FETCH_SERIALIZE ==== ==== PDO::FETCH_SERIALIZE ====
Line 36: Line 33:
 ===== Vote ===== ===== Vote =====
  
-Yes/No.+Voting started 2021-04-14 and ended 2021-04-28. 
 + 
 +<doodle title="Phase out Serializable as proposed?" auth="nikic" voteType="single" closed="true"> 
 +   Yes 
 +   No 
 +</doodle>
  
rfc/phase_out_serializable.1607355978.txt.gz · Last modified: 2020/12/07 15:46 by nikic