[wp-trac] [WordPress Trac] #47699: Remove redundant JSON polyfills for PHP native functionality
WordPress Trac
noreply at wordpress.org
Fri Jul 19 09:30:00 UTC 2019
#47699: Remove redundant JSON polyfills for PHP native functionality
-------------------------------------------------+-------------------------
Reporter: jrf | Owner: (none)
Type: enhancement | Status: new
Priority: normal | Milestone: 5.3
Component: General | Version: trunk
Severity: normal | Resolution:
Keywords: has-patch has-unit-tests needs- | Focuses: coding-
refresh needs-dev-note | standards
-------------------------------------------------+-------------------------
Comment (by jrf):
Replying to [comment:6 pento]:
> The good folks at VaultPress have run some checks across the sites they
monitor, and have found approximately 0.01% of PHP 5.6+ sites don't have
the JSON extension available.
🎉
Thank you good people at VaultPress!
This result is as I expected, but it's great to get confirmation of it.
>
> Giving this some more thought, I'm inclined to remove the polyfills in
WP 5.3, except for `Services_JSON`, which is still used by plugins/themes
(often without even checking if they need to).
I've run some tests to see which wp.org plugins/themes we are talking
about and it looks like it's only really plugins, with the worse offender
being JetPack.
* [https://wpdirectory.net/search/01DG4Q38EBEY74KZTZCWH278M5 Plugins which
appear to include the class-json.php file] - 16 plugins with > 0 installs.
* [https://wpdirectory.net/search/01DG4Q3NCWQ09BFSY5PTQHWZRD Themes which
appear to include the class-json.php file] - 1 theme with 50 installs.
* [https://wpdirectory.net/search/01DG4PXE8R7H6BD92PNMWPHJDP Plugins which
instantiate a `new Services_JSON` instance] - 210 plugins with > 0
installs, though it looks like this includes some false positives with the
class being mentioned in documentation and not actually being
instantiated, like in WordFence, where they use their own, differently
named copy of the file/class.
* [https://wpdirectory.net/search/01DG4PXVSEBD30655KVRWR2J1X Themes which
instantiate a `new Services_JSON` instance] - 3 themes with > 0 installs,
though it looks like 2 out of 3 are false positives, in that they include
their own copy of the `Services_JSON` file which makes them independent of
WP Core.
>
> We can mark `Services_JSON` as deprecated, and put up a dev note to
remind devs that they need to check that `json_last_error()` doesn't exist
before using it.
👍
>
> For the handful of sites that don't have the JSON extension, it'd be
good to push out a fix in WP 5.2.3 that would warn them of this. Site
Health is part of it, but it should also block updates when WP 5.3 is
released, with a relevant error message.
I've just been looking at this, but I haven't been able to find any such
existing check yet for required extensions, though I may be looking in the
wrong place.
If it doesn't exist yet, it would need to be added and it would be useful
if we could re-use the list of required extensions as contained in the
`WP_Site_Health::get_test_php_extensions()` method.
For now, I'm going to start with refreshing the WP 5.3 patch and adding a
separate patch for WP 5.2 Site Health.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/47699#comment:7>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list