From 0bbca2a3aba343aaa1c777d3663fcf60c0ba4035 Mon Sep 17 00:00:00 2001 From: Adam Silverstein Date: Thu, 21 Jul 2022 20:22:09 +0000 Subject: [PATCH] Upgrade/Install: track php extensions and image library support for WebP and AVIF. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- wp-includes/update.php | 36 ++++++++++++++++++++++++++++++++++++ wp-includes/version.php | 2 +- 2 files changed, 37 insertions(+), 1 deletion(-) diff --git a/wp-includes/update.php b/wp-includes/update.php index 04c8aa3ec2..bc295359bf 100644 --- a/wp-includes/update.php +++ b/wp-includes/update.php @@ -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. * diff --git a/wp-includes/version.php b/wp-includes/version.php index 425ef3297d..f2f32610df 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -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.