Make WordPress Core


Ignore:
Timestamp:
09/19/2021 04:59:35 PM (3 years ago)
Author:
SergeyBiryukov
Message:

Coding Standards: Rename the $arrURL variable to $parsed_url in WP_Http_Streams::request().

This fixes a Variable "$arrURL" is not in valid snake_case format WPCS warning.

Follow-up to [8620], [10509], [25044], [25224], [45667], [51823], [51824].

See #53359.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/class-wp-http-streams.php

    r51298 r51825  
    5252        WP_Http::buildCookieHeader( $parsed_args );
    5353
    54         $arrURL = parse_url( $url );
    55 
    56         $connect_host = $arrURL['host'];
    57 
    58         $secure_transport = ( 'ssl' === $arrURL['scheme'] || 'https' === $arrURL['scheme'] );
    59         if ( ! isset( $arrURL['port'] ) ) {
    60             if ( 'ssl' === $arrURL['scheme'] || 'https' === $arrURL['scheme'] ) {
    61                 $arrURL['port']  = 443;
    62                 $secure_transport = true;
     54        $parsed_url = parse_url( $url );
     55
     56        $connect_host = $parsed_url['host'];
     57
     58        $secure_transport = ( 'ssl' === $parsed_url['scheme'] || 'https' === $parsed_url['scheme'] );
     59        if ( ! isset( $parsed_url['port'] ) ) {
     60            if ( 'ssl' === $parsed_url['scheme'] || 'https' === $parsed_url['scheme'] ) {
     61                $parsed_url['port'] = 443;
     62                $secure_transport   = true;
    6363            } else {
    64                 $arrURL['port'] = 80;
     64                $parsed_url['port'] = 80;
    6565            }
    6666        }
    6767
    6868        // Always pass a path, defaulting to the root in cases such as http://example.com.
    69         if ( ! isset( $arrURL['path'] ) ) {
    70             $arrURL['path'] = '/';
     69        if ( ! isset( $parsed_url['path'] ) ) {
     70            $parsed_url['path'] = '/';
    7171        }
    7272
    7373        if ( isset( $parsed_args['headers']['Host'] ) || isset( $parsed_args['headers']['host'] ) ) {
    7474            if ( isset( $parsed_args['headers']['Host'] ) ) {
    75                 $arrURL['host'] = $parsed_args['headers']['Host'];
     75                $parsed_url['host'] = $parsed_args['headers']['Host'];
    7676            } else {
    77                 $arrURL['host'] = $parsed_args['headers']['host'];
     77                $parsed_url['host'] = $parsed_args['headers']['host'];
    7878            }
    7979            unset( $parsed_args['headers']['Host'], $parsed_args['headers']['host'] );
     
    115115                'ssl' => array(
    116116                    'verify_peer'       => $ssl_verify,
    117                     // 'CN_match' => $arrURL['host'], // This is handled by self::verify_ssl_certificate().
     117                    // 'CN_match' => $parsed_url['host'], // This is handled by self::verify_ssl_certificate().
    118118                    'capture_peer_cert' => $ssl_verify,
    119119                    'SNI_enabled'       => true,
     
    145145            } else {
    146146                // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged
    147                 $handle = @stream_socket_client( $connect_host . ':' . $arrURL['port'], $connection_error, $connection_error_str, $connect_timeout, STREAM_CLIENT_CONNECT, $context );
     147                $handle = @stream_socket_client( $connect_host . ':' . $parsed_url['port'], $connection_error, $connection_error_str, $connect_timeout, STREAM_CLIENT_CONNECT, $context );
    148148            }
    149149
     
    155155                $handle = stream_socket_client( 'tcp://' . $proxy->host() . ':' . $proxy->port(), $connection_error, $connection_error_str, $connect_timeout, STREAM_CLIENT_CONNECT, $context );
    156156            } else {
    157                 $handle = stream_socket_client( $connect_host . ':' . $arrURL['port'], $connection_error, $connection_error_str, $connect_timeout, STREAM_CLIENT_CONNECT, $context );
     157                $handle = stream_socket_client( $connect_host . ':' . $parsed_url['port'], $connection_error, $connection_error_str, $connect_timeout, STREAM_CLIENT_CONNECT, $context );
    158158            }
    159159        }
     
    170170        // Verify that the SSL certificate is valid for this request.
    171171        if ( $secure_transport && $ssl_verify && ! $proxy->is_enabled() ) {
    172             if ( ! self::verify_ssl_certificate( $handle, $arrURL['host'] ) ) {
     172            if ( ! self::verify_ssl_certificate( $handle, $parsed_url['host'] ) ) {
    173173                return new WP_Error( 'http_request_failed', __( 'The SSL certificate for the host could not be verified.' ) );
    174174            }
     
    180180            $requestPath = $url;
    181181        } else {
    182             $requestPath = $arrURL['path'] . ( isset( $arrURL['query'] ) ? '?' . $arrURL['query'] : '' );
     182            $requestPath = $parsed_url['path'] . ( isset( $parsed_url['query'] ) ? '?' . $parsed_url['query'] : '' );
    183183        }
    184184
     
    187187        $include_port_in_host_header = (
    188188            ( $proxy->is_enabled() && $proxy->send_through_proxy( $url ) ) ||
    189             ( 'http' === $arrURL['scheme'] && 80 != $arrURL['port'] ) ||
    190             ( 'https' === $arrURL['scheme'] && 443 != $arrURL['port'] )
     189            ( 'http' === $parsed_url['scheme'] && 80 != $parsed_url['port'] ) ||
     190            ( 'https' === $parsed_url['scheme'] && 443 != $parsed_url['port'] )
    191191        );
    192192
    193193        if ( $include_port_in_host_header ) {
    194             $strHeaders .= 'Host: ' . $arrURL['host'] . ':' . $arrURL['port'] . "\r\n";
     194            $strHeaders .= 'Host: ' . $parsed_url['host'] . ':' . $parsed_url['port'] . "\r\n";
    195195        } else {
    196             $strHeaders .= 'Host: ' . $arrURL['host'] . "\r\n";
     196            $strHeaders .= 'Host: ' . $parsed_url['host'] . "\r\n";
    197197        }
    198198
Note: See TracChangeset for help on using the changeset viewer.