Making WordPress.org

Changeset 14332


Ignore:
Timestamp:
01/06/2025 01:37:11 AM (22 months ago)
Author:
dd32
Message:

Pattern Directory: API: Pass a length to ob_start() to avoid a PHP 8.1 segfault on certain requests.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/api.wordpress.org/public_html/patterns/1.0/index.php

    r12147 r14332  
    99 * do any any object caching.
    1010 */
    11 
    1211main( $_SERVER['QUERY_STRING'] );
    1312
    … …  
    2221        // Remove CORS header added by REST API.
    2322        header_remove( 'access-control-allow-headers' );
     23        header_remove( 'access-control-expose-headers' );
    2424
    2525        $replace = true;
    2626
    2727        foreach ( headers_list() as $header ) {
    28                 if ( 'Link: ' === substr( $header, 0, 6) ) {
     28                if (
     29                        str_starts_with( $header, 'Link: ' ) &&
     30                        str_contains( $header, 'wp-json' )
     31                ) {
    2932                        $new_header = str_replace( 'https://wordpress.org/patterns/wp-json/wp/v2/wporg-pattern', 'https://api.wordpress.org/patterns/1.0', $header );
    30                         $new_header = str_replace( 'https://wordpress.org/patterns/wp-json/', 'https://api.wordpress.org/patterns/1.0/', $new_header );
     33                        $new_header = str_replace( 'https://wordpress.org/patterns/wp-json/',                    'https://api.wordpress.org/patterns/1.0/', $new_header );
    3134                        if ( $new_header !== $header ) {
    3235                                header( $new_header, $replace );
    … …  
    7982        $wp_init_host = $api_url_base . $endpoint . '?' . urldecode( http_build_query( $query_args ) );
    8083
    81         ob_start( __NAMESPACE__ . '\flush_handler' );
     84        ob_start( __NAMESPACE__ . '\flush_handler', 8192 );
    8285
    8386        // Load WordPress to process the request and output the response.
Note: See TracChangeset for help on using the changeset viewer.