diff --git a/composer.json b/composer.json index eb78d144e590c..76b0b9b3991d6 100644 --- a/composer.json +++ b/composer.json @@ -10,6 +10,7 @@ "issues": "https://core.trac.wordpress.org/" }, "require": { + "ext-hash": "*", "ext-json": "*", "php": ">=7.2.24" }, diff --git a/src/wp-admin/includes/class-wp-site-health.php b/src/wp-admin/includes/class-wp-site-health.php index 3f89fc0a38ffc..19d109d447283 100644 --- a/src/wp-admin/includes/class-wp-site-health.php +++ b/src/wp-admin/includes/class-wp-site-health.php @@ -923,7 +923,7 @@ public function get_test_php_extensions() { ), 'hash' => array( 'function' => 'hash', - 'required' => false, + 'required' => true, ), 'imagick' => array( 'extension' => 'imagick', diff --git a/src/wp-admin/includes/update-core.php b/src/wp-admin/includes/update-core.php index a29f389860127..7b6ce67146649 100644 --- a/src/wp-admin/includes/update-core.php +++ b/src/wp-admin/includes/update-core.php @@ -1009,9 +1009,6 @@ * @global array $_old_requests_files * @global array $_new_bundled_files * @global wpdb $wpdb WordPress database abstraction object. - * @global string $wp_version - * @global string $required_php_version - * @global string $required_mysql_version * * @param string $from New release unzipped path. * @param string $to Path to old WordPress installation. @@ -1075,7 +1072,7 @@ function update_core( $from, $to ) { } /* - * Import $wp_version, $required_php_version, and $required_mysql_version from the new version. + * Import $wp_version, $required_php_version, $required_php_extensions, and $required_mysql_version from the new version. * DO NOT globalize any variables imported from `version-current.php` in this function. * * BC Note: $wp_filesystem->wp_content_dir() returned unslashed pre-2.8. @@ -1181,17 +1178,25 @@ function update_core( $from, $to ) { ); } - // Add a warning when the JSON PHP extension is missing. - if ( ! extension_loaded( 'json' ) ) { - return new WP_Error( - 'php_not_compatible_json', - 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' - ) - ); + $missing_extensions = new WP_Error(); + + foreach ( $required_php_extensions as $extension ) { + if ( ! extension_loaded( $extension ) ) { + $missing_extensions->add( + "php_not_compatible_{$extension}", + 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, + $extension + ) + ); + } + } + + // Add a warning when required PHP extensions are missing. + if ( $missing_extensions->has_errors() ) { + return $missing_extensions; } /** This filter is documented in wp-admin/includes/update-core.php */ diff --git a/src/wp-admin/install.php b/src/wp-admin/install.php index e81331acfc82e..2eb2053f00d27 100644 --- a/src/wp-admin/install.php +++ b/src/wp-admin/install.php @@ -232,12 +232,13 @@ function display_setup_form( $error = null ) { } /** - * @global string $wp_version The WordPress version string. - * @global string $required_php_version The required PHP version string. - * @global string $required_mysql_version The required MySQL version string. - * @global wpdb $wpdb WordPress database abstraction object. + * @global string $wp_version The WordPress version string. + * @global string $required_php_version The required PHP version string. + * @global string[] $required_php_extensions The names of required PHP extensions. + * @global string $required_mysql_version The required MySQL version string. + * @global wpdb $wpdb WordPress database abstraction object. */ -global $wp_version, $required_php_version, $required_mysql_version, $wpdb; +global $wp_version, $required_php_version, $required_php_extensions, $required_mysql_version, $wpdb; $php_version = PHP_VERSION; $mysql_version = $wpdb->db_version(); @@ -298,6 +299,25 @@ function display_setup_form( $error = null ) { die( '
' . $compat . '