rfc:always_enable_json

Differences

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

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
rfc:always_enable_json [2020/04/30 00:02] tandrerfc:always_enable_json [2020/05/27 13:15] (current) tandre
Line 1: Line 1:
-====== PHP RFC: Always Available JSON extension ====== +====== PHP RFC: Always available JSON extension ====== 
-  * Version: 0.2+  * Version: 0.3
   * Date: 2020-04-29   * Date: 2020-04-29
   * Author: Tyson Andre <tandre@php.net>   * Author: Tyson Andre <tandre@php.net>
-  * Status: Under Discussion+  * Status: Implemented
   * Target version: PHP 8.0   * Target version: PHP 8.0
   * Implementation: https://github.com/php/php-src/pull/5495   * Implementation: https://github.com/php/php-src/pull/5495
Line 10: Line 10:
 ===== Introduction ===== ===== Introduction =====
  
-Currently, it's possible to disable the json extension with ''./configure --disable-json''.+Currently, it's possible to disable the json extension with ''./configure %%--%%disable-json''.
 However, JSON is extremely useful to have because it's widely used for many use cases (web sites, logging output, However, JSON is extremely useful to have because it's widely used for many use cases (web sites, logging output,
 and as a data format that can be used to share data with many applications and as a data format that can be used to share data with many applications
Line 18: Line 18:
 Examples of where this would be useful: Examples of where this would be useful:
  
-  * Allowing internal classes to implement ''JsonSerializable'', which currently requires a hard dependency on the JSON extension. \\ (e.g. ''DateTime'' already has custom JSON serialization behavior, but is unable to implement ''JsonSerializable'' normally)+  * Allowing internal classes to implement ''JsonSerializable'', which currently requires a hard dependency on the JSON extension. \\ (e.g. ''DateTime'' already has custom JSON serialization behavior, but is unable to implement ''JsonSerializable'' because that interface doesn't always exist.)
  
   * Allowing PHP users to publish single-file scripts that use json_encode and json_decode and don't require polyfills or less readable var_export output. \\   (polyfills are less efficient and may have issues with recursive data structures)   * Allowing PHP users to publish single-file scripts that use json_encode and json_decode and don't require polyfills or less readable var_export output. \\   (polyfills are less efficient and may have issues with recursive data structures)
Line 41: Line 41:
 ===== Backward Incompatible Changes ===== ===== Backward Incompatible Changes =====
  
-Build configurations that contain ''--enable-json'' or ''--disable-json'' will have to be updated, as the argument will cease to exist. +Build configurations that contain ''%%--%%enable-json'' or ''%%--%%disable-json'' will have to be updated, as the argument will cease to exist.
- +
-The ''HAVE_JSON'' C macro constant was removed from the generated ''main/php_config.h'', because it's always true (the removal of macros that are no longer useful are typically reserved for major versions such as 8.0). +
- +
-  * PECL extensions should check ''#if PHP_MAJOR_VERSION >= 8 || HAVE_JSON'' instead of ''#if HAVE_JSON''+
  
 Because JSON would always be built statically to guarantee it can be used, package maintainers for OSes such as Fedora would need to create stub packages for the ''php-json'' package, or to remove the package in php 8 (or mark it as provided by the core ''php'' package). Because JSON would always be built statically to guarantee it can be used, package maintainers for OSes such as Fedora would need to create stub packages for the ''php-json'' package, or to remove the package in php 8 (or mark it as provided by the core ''php'' package).
Line 69: Line 65:
  
 ===== Future Scope ===== ===== Future Scope =====
 +
 +  * Make internal classes that already have custom JSON serialization behavior (''ZEND_PROP_PURPOSE_JSON'' in property array getters) start implementing ''JsonSerializable'', and add implementations of jsonSerialize() returning arrays (e.g. for ''DateTime'', ''DateTimeZone'', ''DateTimeImmutable'', ''DateTimeZone''. (Changing ''ArrayObject'' wouldn't make sense, because php users rely on php serializing those with object syntax (e.g. ''{}'' instead of ''[]'')))
  
   * Start using JSON in more places within PHP's own functions. For example, adding additional conversion specifiers for ''printf()'' such as ''%j'' or ''%v'' to PHP to call JSON with the default options.   * Start using JSON in more places within PHP's own functions. For example, adding additional conversion specifiers for ''printf()'' such as ''%j'' or ''%v'' to PHP to call JSON with the default options.
Line 74: Line 72:
   * Add alternative options to use JSON to dump debug output in an easily machine-readable form. (e.g. ''opcache.opt_debug_level'' debug output is plaintext right now)   * Add alternative options to use JSON to dump debug output in an easily machine-readable form. (e.g. ''opcache.opt_debug_level'' debug output is plaintext right now)
  
-===== Proposed Voting Choices =====+===== Vote ===== 
 + 
 +Voting started 2020-05-13 and ends 2020-05-27. 
 + 
 +<doodle title="Make the JSON extension impossible to disable" auth="tandre" voteType="single" closed="true"> 
 +   * Yes 
 +   * No 
 +</doodle> 
 + 
 +===== Changelog =====
  
-Make the JSON extension impossible to disable (Yes/No voterequiring 2/3 majority)+0.3: Keep the HAVE_JSON constant in config.m4to avoid a backwards compatibility break.
  
 ===== References ===== ===== References =====
rfc/always_enable_json.1588204941.txt.gz · Last modified: 2020/04/30 00:02 by tandre