Making WordPress.org


Ignore:
Timestamp:
04/28/2026 04:18:45 PM (6 months ago)
Author:
coffee2code
Message:

PHPUnit Test Reporter: Sync with git WordPress/phpunit-test-reporter@fa1fa7b

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/phpunit-test-reporter/src/class-restapi.php

    r14828 r14850  
    1919                                'callback'            => array( __CLASS__, 'add_performance_results_callback' ),
    2020                                'args'                => array(
    21                                         'results' => array(
     21                                        'results'          => array(
    2222                                                'required'          => true,
    23                                                 'description'       => 'Performance test results in JSON format.',
     23                                                'description'       => 'Performance test results keyed by approach and scenario.',
     24                                                'type'              => 'object',
     25                                                'validate_callback' => array( __CLASS__, 'validate_callback' ),
     26                                        ),
     27                                        'env'              => array(
     28                                                'required'          => true,
     29                                                'description'       => 'Environment information for the test run.',
     30                                                'type'              => 'object',
     31                                                'validate_callback' => array( __CLASS__, 'validate_callback' ),
     32                                        ),
     33                                        'environment_name' => array(
     34                                                'required'          => false,
     35                                                'description'       => 'Human-readable label for the environment under test.',
    2436                                                'type'              => 'string',
    25                                                 'validate_callback' => array( __CLASS__, 'validate_callback' ),
    26                                         ),
    27                                         'env'     => array(
    28                                                 'required'          => true,
    29                                                 'description'       => 'JSON blob containing environment information.',
    30                                                 'type'              => 'string',
    31                                                 'validate_callback' => array( __CLASS__, 'validate_callback' ),
     37                                                'sanitize_callback' => 'sanitize_text_field',
    3238                                        ),
    3339                                ),
    … …  
    8793                        case 'env':
    8894                        case 'results':
    89                                 if ( null === json_decode( $value ) ) {
     95                                if ( is_string( $value ) && null === json_decode( $value ) ) {
    9096                                        return new WP_Error(
    9197                                                'rest_invalid',
    … …  
    123129                $parameters = $data->get_params();
    124130
    125                 $env     = json_decode( $parameters['env'], true );
    126                 $results = json_decode( $parameters['results'], true );
     131                // env and results are decoded by the REST API when Content-Type is application/json.
     132                $env     = is_array( $parameters['env'] ) ? $parameters['env'] : (array) json_decode( $parameters['env'], true );
     133                $results = is_array( $parameters['results'] ) ? $parameters['results'] : (array) json_decode( $parameters['results'], true );
    127134
    128135                $php_version = '';
    … …  
    133140
    134141                $db_version = ! empty( $env['mysql_version'] ) ? $env['mysql_version'] : '';
    135                 $wp_version = ! empty( $env['wp_version'] ) ? wp_kses( $env['wp_version'], [] ) : '';
    136                 $env_name   = ! empty( $env['label'] ) ? wp_kses( $env['label'], [] ) : '';
     142                $wp_version = ! empty( $env['wp_version'] ) ? strip_tags( $env['wp_version'] ) : '';
     143
     144                $env_name = ! empty( $parameters['environment_name'] ) ? strip_tags( $parameters['environment_name'] ) : '';
    137145
    138146                $current_user = wp_get_current_user();
Note: See TracChangeset for help on using the changeset viewer.