[wp-trac] [WordPress Trac] #47699: Remove redundant JSON polyfills for PHP native functionality

WordPress Trac noreply at wordpress.org
Sun Jul 14 19:41:55 UTC 2019


#47699: Remove redundant JSON polyfills for PHP native functionality
-------------------------------------------------+-------------------------
 Reporter:  jrf                                  |       Owner:  (none)
     Type:  enhancement                          |      Status:  new
 Priority:  normal                               |   Milestone:  Awaiting
                                                 |  Review
Component:  General                              |     Version:  trunk
 Severity:  normal                               |  Resolution:
 Keywords:  has-patch 2nd-opinion has-unit-      |     Focuses:  coding-
  tests                                          |  standards
-------------------------------------------------+-------------------------

Comment (by jrf):

 @Clorith You bring up a valid consideration.

 However:

 > There is no installation needed to use these functions; they are part of
 the PHP core.
 Source: https://www.php.net/manual/en/json.requirements.php

 > As of PHP 5.2.0, the JSON extension is bundled and compiled into PHP by
 default.
 Source: https://www.php.net/manual/en/json.installation.php

 And while it looks like there ''is'' [https://github.com/php/php-
 src/blob/master/ext/json/config.m4 an undocumented option to `--disable-
 json`], any host offering PHP without the JSON extension is willfully
 breaking PHP and should be **''burned at the stake''** (she says in jest).

 All comments regarding disabled JSON extensions in the PHP manual are at
 least five years old, no new comments to that effect have been added
 since, so I'm hoping this means that hosts have wizened up.

 I also don't think that numbers from 8 years ago when 5.3 was the latest &
 greatest PHP version can in any way compare with the current landscape.


 > Perhaps a golden middle ground could be taken in this instance, one
 where we deprecate the polyfills for 1-2 major core releases, where we
 implement a _doing_it_wrong when the polyfills that should be safe to
 remove are used. This should give ample warning in scenarios where they
 are used, while also covering our backs in the process?
 >
 > In fact, I think a deprecation route such as this would be beneficial
 for any polyfill slated for removal.

 While I agree, that ''might'' be a valid route for something like the
 `Services_JSON` class, for anything that is Core PHP, deprecation should
 be redundant.

 All the same, if people are seriously wary of this, I propose the
 following:
 * Add `_deprecated_xxx()` calls in all relevant places in WP 5.3.
 * Remove work-arounds for differences across PHP versions in WP 5.3. Those
 already don't take the polyfills into account as they are based on PHP
 versions, so this should not cause any problems which don't exist already
 🙃
 * Add the `JSON` extension as a required extension to the list in Site
 Health in WP 5.3. (''Why the heck isn't it listed there now ?!?!?!'')
 * Execute the removal in WP 5.5 at the latest or by the end of the year in
 the same version as the next PHP version bump, whichever comes sooner.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/47699#comment:2>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list