From 1bcd41b7c1aabc4c28ed9d16d90154e21c97cf6f Mon Sep 17 00:00:00 2001 From: Jonathan Desrosiers Date: Wed, 9 Oct 2019 22:20:37 +0000 Subject: [PATCH] Upgrade/Install: Detect the presence of the native PHP JSON extension before updating. The PHP native JSON extension has been bundled and compiled with PHP by default since version 5.2.0. Because the minimum version of PHP required by WordPress is now 5.6.20 (see #46594 and [45058]), the related polyfills and workarounds have been removed (see [46205-46206,46208]). However, even though the JSON extension is now included in PHP by default, it is still possible to disable the extension in a custom configuration. This change will prevent sites from upgrading if the JSON extension is disabled to prevent compatibility issues. Props jrf, jorbin, dd32, desrosj. Fixes #47699. git-svn-id: https://develop.svn.wordpress.org/trunk@46455 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-admin/includes/update-core.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/wp-admin/includes/update-core.php b/src/wp-admin/includes/update-core.php index 8df6150356..b2f7c7d711 100644 --- a/src/wp-admin/includes/update-core.php +++ b/src/wp-admin/includes/update-core.php @@ -1001,6 +1001,19 @@ function update_core( $from, $to ) { ); } + // Add a warning when the JSON Extension is missing. + if ( ! extension_loaded( 'json' ) ) { + return new WP_Error( + 'php_not_compatible', + sprintf( + /* translators: 1: WordPress version number, 2: The PHP Extension name needed. */ + __( 'The update cannot be installed because WordPress %1$s requires the %2$s PHP Extension.' ), + $wp_version, + 'JSON' + ) + ); + } + /** This filter is documented in wp-admin/includes/update-core.php */ apply_filters( 'update_feedback', __( 'Preparing to install the latest version…' ) );