From ae757491f57e0bb982bfaf249e7fa5b0d8e53f6c Mon Sep 17 00:00:00 2001 From: Adam Silverstein Date: Thu, 21 Jul 2022 20:20:52 +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. git-svn-id: https://develop.svn.wordpress.org/trunk@53753 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/update.php | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/src/wp-includes/update.php b/src/wp-includes/update.php index 04c8aa3ec2..bc295359bf 100644 --- a/src/wp-includes/update.php +++ b/src/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. *