Upgrade/Install: track php extensions and image library support for WebP and AVIF.

Add the loaded php extensions as well as whether the server's image libraries support WebP and AVIF image formats to the data payload sent during upgrade checks. Collecting this data with the WordPress.org API will help the project make more data driven decisions about feature support. Note that all data can still be filtered with the `core_version_check_query_args` filter for privacy reasons.

Props dd32, SergeyBiryukov, mikeschroder, pbiron. 
Fixes #48116.


Built from https://develop.svn.wordpress.org/trunk@53753


git-svn-id: http://core.svn.wordpress.org/trunk@53312 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Adam Silverstein 2022-07-21 20:22:09 +00:00
parent 6b06b2cc25
commit 0bbca2a3ab
2 changed files with 37 additions and 1 deletions

View File

@ -89,6 +89,8 @@ function wp_version_check( $extra_stats = array(), $force_check = false ) {
$wp_install = home_url( '/' );
}
$extensions = get_loaded_extensions();
sort( $extensions, SORT_STRING | SORT_FLAG_CASE );
$query = array(
'version' => $wp_version,
'php' => $php_version,
@ -99,8 +101,42 @@ function wp_version_check( $extra_stats = array(), $force_check = false ) {
'users' => get_user_count(),
'multisite_enabled' => $multisite_enabled,
'initial_db_version' => get_site_option( 'initial_db_version' ),
'extensions' => array_combine( $extensions, array_map( 'phpversion', $extensions ) ),
'platform_flags' => array(
'os' => PHP_OS,
'bits' => PHP_INT_SIZE === 4 ? 32 : 64,
),
'image_support' => array(),
);
if ( function_exists( 'gd_info' ) ) {
$gd_info = gd_info();
// Filter to supported values.
$gd_info = array_filter( $gd_info );
// Add data for GD WebP and AVIF support.
$query['image_support']['gd'] = array_keys(
array_filter(
array(
'webp' => isset( $gd_info['WebP Support'] ),
'avif' => isset( $gd_info['AVIF Support'] ),
)
)
);
}
if ( class_exists( 'Imagick' ) ) {
// Add data for Imagick WebP and AVIF support.
$query['image_support']['imagick'] = array_keys(
array_filter(
array(
'webp' => ! empty( Imagick::queryFormats( 'WEBP' ) ),
'avif' => ! empty( Imagick::queryFormats( 'AVIF' ) ),
)
)
);
}
/**
* Filters the query arguments sent as part of the core version check.
*

View File

@ -16,7 +16,7 @@
*
* @global string $wp_version
*/
$wp_version = '6.1-alpha-53752';
$wp_version = '6.1-alpha-53753';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.