Make WordPress Core

Changeset 53753


Ignore:
Timestamp:
07/21/2022 08:20:52 PM (2 years ago)
Author:
adamsilverstein
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/update.php

    r53455 r53753  
    9090    }
    9191
     92    $extensions = get_loaded_extensions();
     93    sort( $extensions, SORT_STRING | SORT_FLAG_CASE );
    9294    $query = array(
    9395        'version'            => $wp_version,
     
    100102        'multisite_enabled'  => $multisite_enabled,
    101103        'initial_db_version' => get_site_option( 'initial_db_version' ),
     104        'extensions'         => array_combine( $extensions, array_map( 'phpversion', $extensions ) ),
     105        'platform_flags'     => array(
     106            'os'   => PHP_OS,
     107            'bits' => PHP_INT_SIZE === 4 ? 32 : 64,
     108        ),
     109        'image_support'      => array(),
    102110    );
     111
     112    if ( function_exists( 'gd_info' ) ) {
     113        $gd_info = gd_info();
     114        // Filter to supported values.
     115        $gd_info = array_filter( $gd_info );
     116
     117        // Add data for GD WebP and AVIF support.
     118        $query['image_support']['gd'] = array_keys(
     119            array_filter(
     120                array(
     121                    'webp' => isset( $gd_info['WebP Support'] ),
     122                    'avif' => isset( $gd_info['AVIF Support'] ),
     123                )
     124            )
     125        );
     126    }
     127
     128    if ( class_exists( 'Imagick' ) ) {
     129        // Add data for Imagick WebP and AVIF support.
     130        $query['image_support']['imagick'] = array_keys(
     131            array_filter(
     132                array(
     133                    'webp' => ! empty( Imagick::queryFormats( 'WEBP' ) ),
     134                    'avif' => ! empty( Imagick::queryFormats( 'AVIF' ) ),
     135                )
     136            )
     137        );
     138    }
    103139
    104140    /**
Note: See TracChangeset for help on using the changeset viewer.