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
This commit is contained in:
Jonathan Desrosiers 2019-10-09 22:20:37 +00:00
parent 22d50c492d
commit 1bcd41b7c1
1 changed files with 13 additions and 0 deletions

View File

@ -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…' ) );