Make WordPress Core

Ticket #40784: 40784.diff

File 40784.diff, 2.1 KB (added by tfrommen, 7 years ago)
  • tests/phpunit/tests/xmlrpc/client.php

    IDEA additional info:
    Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
    <+>UTF-8
     
    2626                $this->assertFalse( $client->port );
    2727                $this->assertEquals( '/server.php?this-is-needed=true', $client->path );
    2828        }
     29
     30        /**
     31         * @ticket 40784
     32         */
     33        function test_wp_ixr_client_can_handle_protocolless_urls() {
     34                $client = new WP_HTTP_IXR_Client( '//example.com/server.php' );
     35                $this->assertEquals( '', $client->scheme );
     36                $this->assertEquals( 'example.com', $client->server );
     37        }
     38
     39        /**
     40         * @ticket 40784
     41         */
     42        function test_wp_ixr_client_can_handle_relative_urls() {
     43                $client = new WP_HTTP_IXR_Client( '/server.php' );
     44                $this->assertEquals( '', $client->scheme );
     45                $this->assertEquals( '', $client->server );
     46                $this->assertEquals( '/server.php', $client->path );
     47        }
     48
     49        /**
     50         * @ticket 40784
     51         */
     52        function test_wp_ixr_client_can_handle_invalid_urls() {
     53                $client = new WP_HTTP_IXR_Client( '' );
     54                $this->assertEquals( '', $client->scheme );
     55                $this->assertEquals( '', $client->server );
     56                $this->assertEquals( '', $client->path );
     57        }
    2958}
    3059
  • src/wp-includes/class-wp-http-ixr-client.php

    IDEA additional info:
    Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
    <+>UTF-8
     
    2323                if ( ! $path ) {
    2424                        // Assume we have been given a URL instead
    2525                        $bits = parse_url($server);
    26                         $this->scheme = $bits['scheme'];
    27                         $this->server = $bits['host'];
     26                        $this->scheme = isset($bits['scheme']) ? $bits['scheme'] : '';
     27                        $this->server = isset($bits['host']) ? $bits['host'] : '';
    2828                        $this->port = isset($bits['port']) ? $bits['port'] : $port;
    2929                        $this->path = !empty($bits['path']) ? $bits['path'] : '/';
    3030