Site Health: Update PHP extension tests to reflect the current state of the Hosting Teams handbook recommendations.
Props Clorith, bronsonquick, jrf, johnbillion, galbaras, mikeschroder, jorbin. Fixes #47454. Built from https://develop.svn.wordpress.org/trunk@46268 git-svn-id: http://core.svn.wordpress.org/trunk@46080 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
9510aaecde
commit
db5f9f7a3a
|
@ -727,15 +727,18 @@ class WP_Site_Health {
|
||||||
* Make the check for available PHP modules into a simple boolean operator for a cleaner test runner.
|
* Make the check for available PHP modules into a simple boolean operator for a cleaner test runner.
|
||||||
*
|
*
|
||||||
* @since 5.2.0
|
* @since 5.2.0
|
||||||
|
* @since 5.3.0 The `$constant` and `$class` parameters were added.
|
||||||
*
|
*
|
||||||
* @param string $extension Optional. The extension name to test. Default null.
|
* @param string $extension Optional. The extension name to test. Default null.
|
||||||
* @param string $function Optional. The function name to test. Default null.
|
* @param string $function Optional. The function name to test. Default null.
|
||||||
|
* @param string $constant Optional. The constant name to test for. Default null.
|
||||||
|
* @param string $class Optional. The class name to test for. Default null.
|
||||||
*
|
*
|
||||||
* @return bool Whether or not the extension and function are available.
|
* @return bool Whether or not the extension and function are available.
|
||||||
*/
|
*/
|
||||||
private function test_php_extension_availability( $extension = null, $function = null ) {
|
private function test_php_extension_availability( $extension = null, $function = null, $constant = null, $class = null ) {
|
||||||
// If no extension or function is passed, claim to fail testing, as we have nothing to test against.
|
// If no extension or function is passed, claim to fail testing, as we have nothing to test against.
|
||||||
if ( ! $extension && ! $function ) {
|
if ( ! $extension && ! $function && ! $constant && ! $class ) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -745,6 +748,12 @@ class WP_Site_Health {
|
||||||
if ( $function && ! function_exists( $function ) ) {
|
if ( $function && ! function_exists( $function ) ) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
if ( $constant && ! defined( $constant ) ) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if ( $class && ! class_exists( $class ) ) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -788,36 +797,40 @@ class WP_Site_Health {
|
||||||
);
|
);
|
||||||
|
|
||||||
$modules = array(
|
$modules = array(
|
||||||
'bcmath' => array(
|
|
||||||
'function' => 'bcadd',
|
|
||||||
'required' => false,
|
|
||||||
),
|
|
||||||
'curl' => array(
|
'curl' => array(
|
||||||
'function' => 'curl_version',
|
'function' => 'curl_version',
|
||||||
'required' => false,
|
'required' => false,
|
||||||
),
|
),
|
||||||
|
'dom' => array(
|
||||||
|
'class' => 'DOMNode',
|
||||||
|
'required' => false,
|
||||||
|
),
|
||||||
'exif' => array(
|
'exif' => array(
|
||||||
'function' => 'exif_read_data',
|
'function' => 'exif_read_data',
|
||||||
'required' => false,
|
'required' => false,
|
||||||
),
|
),
|
||||||
'filter' => array(
|
|
||||||
'function' => 'filter_list',
|
|
||||||
'required' => false,
|
|
||||||
),
|
|
||||||
'fileinfo' => array(
|
'fileinfo' => array(
|
||||||
'function' => 'finfo_file',
|
'function' => 'finfo_file',
|
||||||
'required' => false,
|
'required' => false,
|
||||||
),
|
),
|
||||||
'mod_xml' => array(
|
'hash' => array(
|
||||||
'extension' => 'libxml',
|
'function' => 'hash',
|
||||||
'required' => false,
|
'required' => false,
|
||||||
|
),
|
||||||
|
'json' => array(
|
||||||
|
'function' => 'json_last_error',
|
||||||
|
'required' => true,
|
||||||
|
),
|
||||||
|
'mbstring' => array(
|
||||||
|
'function' => 'mb_check_encoding',
|
||||||
|
'required' => false,
|
||||||
),
|
),
|
||||||
'mysqli' => array(
|
'mysqli' => array(
|
||||||
'function' => 'mysqli_connect',
|
'function' => 'mysqli_connect',
|
||||||
'required' => false,
|
'required' => false,
|
||||||
),
|
),
|
||||||
'libsodium' => array(
|
'libsodium' => array(
|
||||||
'function' => 'sodium_compare',
|
'constant' => 'SODIUM_LIBRARY_VERSION',
|
||||||
'required' => false,
|
'required' => false,
|
||||||
'php_bundled_version' => '7.2.0',
|
'php_bundled_version' => '7.2.0',
|
||||||
),
|
),
|
||||||
|
@ -833,20 +846,41 @@ class WP_Site_Health {
|
||||||
'extension' => 'imagick',
|
'extension' => 'imagick',
|
||||||
'required' => false,
|
'required' => false,
|
||||||
),
|
),
|
||||||
|
'mod_xml' => array(
|
||||||
|
'extension' => 'libxml',
|
||||||
|
'required' => false,
|
||||||
|
),
|
||||||
|
'zip' => array(
|
||||||
|
'class' => 'ZipArchive',
|
||||||
|
'required' => false,
|
||||||
|
),
|
||||||
|
'filter' => array(
|
||||||
|
'function' => 'filter_list',
|
||||||
|
'required' => false,
|
||||||
|
),
|
||||||
'gd' => array(
|
'gd' => array(
|
||||||
'extension' => 'gd',
|
'extension' => 'gd',
|
||||||
'required' => false,
|
'required' => false,
|
||||||
'fallback_for' => 'imagick',
|
'fallback_for' => 'imagick',
|
||||||
),
|
),
|
||||||
|
'iconv' => array(
|
||||||
|
'function' => 'iconv',
|
||||||
|
'required' => false,
|
||||||
|
),
|
||||||
'mcrypt' => array(
|
'mcrypt' => array(
|
||||||
'extension' => 'mcrypt',
|
'extension' => 'mcrypt',
|
||||||
'required' => false,
|
'required' => false,
|
||||||
'fallback_for' => 'libsodium',
|
'fallback_for' => 'libsodium',
|
||||||
),
|
),
|
||||||
|
'simplexml' => array(
|
||||||
|
'extension' => 'simplexml',
|
||||||
|
'required' => false,
|
||||||
|
'fallback_for' => 'mod_xml',
|
||||||
|
),
|
||||||
'xmlreader' => array(
|
'xmlreader' => array(
|
||||||
'extension' => 'xmlreader',
|
'extension' => 'xmlreader',
|
||||||
'required' => false,
|
'required' => false,
|
||||||
'fallback_for' => 'xml',
|
'fallback_for' => 'mod_xml',
|
||||||
),
|
),
|
||||||
'zlib' => array(
|
'zlib' => array(
|
||||||
'extension' => 'zlib',
|
'extension' => 'zlib',
|
||||||
|
@ -859,6 +893,7 @@ class WP_Site_Health {
|
||||||
* An array representing all the modules we wish to test for.
|
* An array representing all the modules we wish to test for.
|
||||||
*
|
*
|
||||||
* @since 5.2.0
|
* @since 5.2.0
|
||||||
|
* @since 5.3.0 The `$constant` and `$class` parameters were added.
|
||||||
*
|
*
|
||||||
* @param array $modules {
|
* @param array $modules {
|
||||||
* An associated array of modules to test for.
|
* An associated array of modules to test for.
|
||||||
|
@ -869,6 +904,8 @@ class WP_Site_Health {
|
||||||
*
|
*
|
||||||
* string $function Optional. A function name to test for the existence of.
|
* string $function Optional. A function name to test for the existence of.
|
||||||
* string $extension Optional. An extension to check if is loaded in PHP.
|
* string $extension Optional. An extension to check if is loaded in PHP.
|
||||||
|
* string $constant Optional. A constant name to check for to verify an extension exists.
|
||||||
|
* string $class Optional. A class name to check for to verify an extension exists.
|
||||||
* bool $required Is this a required feature or not.
|
* bool $required Is this a required feature or not.
|
||||||
* string $fallback_for Optional. The module this module replaces as a fallback.
|
* string $fallback_for Optional. The module this module replaces as a fallback.
|
||||||
* }
|
* }
|
||||||
|
@ -879,8 +916,10 @@ class WP_Site_Health {
|
||||||
$failures = array();
|
$failures = array();
|
||||||
|
|
||||||
foreach ( $modules as $library => $module ) {
|
foreach ( $modules as $library => $module ) {
|
||||||
$extension = ( isset( $module['extension'] ) ? $module['extension'] : null );
|
$extension = ( isset( $module['extension'] ) ? $module['extension'] : null );
|
||||||
$function = ( isset( $module['function'] ) ? $module['function'] : null );
|
$function = ( isset( $module['function'] ) ? $module['function'] : null );
|
||||||
|
$constant = ( isset( $module['constant'] ) ? $module['constant'] : null );
|
||||||
|
$class_name = ( isset( $module['class'] ) ? $module['class'] : null );
|
||||||
|
|
||||||
// If this module is a fallback for another function, check if that other function passed.
|
// If this module is a fallback for another function, check if that other function passed.
|
||||||
if ( isset( $module['fallback_for'] ) ) {
|
if ( isset( $module['fallback_for'] ) ) {
|
||||||
|
@ -895,7 +934,7 @@ class WP_Site_Health {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! $this->test_php_extension_availability( $extension, $function ) && ( ! isset( $module['php_bundled_version'] ) || version_compare( PHP_VERSION, $module['php_bundled_version'], '<' ) ) ) {
|
if ( ! $this->test_php_extension_availability( $extension, $function, $constant, $class_name ) && ( ! isset( $module['php_bundled_version'] ) || version_compare( PHP_VERSION, $module['php_bundled_version'], '<' ) ) ) {
|
||||||
if ( $module['required'] ) {
|
if ( $module['required'] ) {
|
||||||
$result['status'] = 'critical';
|
$result['status'] = 'critical';
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
*
|
*
|
||||||
* @global string $wp_version
|
* @global string $wp_version
|
||||||
*/
|
*/
|
||||||
$wp_version = '5.3-alpha-46267';
|
$wp_version = '5.3-alpha-46268';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||||
|
|
Loading…
Reference in New Issue