Making WordPress.org


Ignore:
Timestamp:
02/28/2018 03:27:07 AM (5 years ago)
Author:
dd32
Message:

API: Serve Happy: Update the API to return the final selection of fields.

Props flixos90.
Fixes #3474.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/api.wordpress.org/public_html/core/serve-happy/1.0/include.php

    r6728 r6806  
    1919    }
    2020
    21     // Including the IP address here as an optional parameter incase it's wanted later to return dynamic responses for hosts.
    22     $ip_adress = false;
    23     if ( ! empty( $request['ip_address'] ) ) {
    24         $ip_address = $request['ip_address'];
    25 
    26         // Only allow a IP range to be passed. for example: 123.123.123.0 instead of 123.123.123.45
    27         if ( '.0' != substr( $ip_address, -2 ) ) {
    28             return bail( 'invalid_param', 'Invalid parameter: ip_address', 400 );
    29         }
    30     }
    31 
    32     return compact(
    33         'php_version',
    34         'ip_address'
    35     );
     21    return compact( 'php_version' );
    3622}
    3723
     
    3925    $php_version = $request['php_version'];
    4026
    41     $out_of_date                = version_compare( $php_version, TRIGGER_PHP_VERSION,            '<'  );
    42     $receiving_security_updates = version_compare( $php_version, PHP_RECEIVING_SECURITY_UPDATES, '>=' );
    43 
    44     $status = 'ok';
    45     if ( $out_of_date ) {
    46         $status = 'out_of_date';
    47     } elseif ( ! $receiving_security_updates ) {
    48         $status = 'no_security_updates';
    49     }
    50 
    51     $recommended_php = RECOMMENDED_PHP;
    52     $secure_php      = PHP_RECEIVING_SECURITY_UPDATES;
    53     $update_url      = ''; // Potential future use based on $request['ip_address']
    54 
    55     return compact(
    56         'php_version',
    57         'recommended_php',
    58         'secure_php',
    59         'status',
    60         'update_url',
    61 
    62         // Including for debugging purposes, see https://meta.trac.wordpress.org/ticket/3474
    63         'out_of_date',
    64         'receiving_security_updates'
     27    return array(
     28        'recommended_version' => RECOMMENDED_PHP,
     29        'is_supported'        => version_compare( $php_version, SUPPORTED_PHP, '>=' ),
     30        'is_secure'           => version_compare( $php_version, SECURE_PHP, '>=' ),
     31        'is_acceptable'       => version_compare( $php_version, ACCEPTABLE_PHP, '>=' ),
    6532    );
    6633}
Note: See TracChangeset for help on using the changeset viewer.