From 0ed014743d9a9d05f2bf664879bb852330c9b6a3 Mon Sep 17 00:00:00 2001 From: Andrew Nacin Date: Sat, 15 Mar 2014 05:00:27 +0000 Subject: [PATCH] Allow query strings for servers in IXR_Client and WP_HTTP_IXR_Client. props cfinke. fixes #26947. git-svn-id: https://develop.svn.wordpress.org/trunk@27552 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/class-IXR.php | 4 +++ src/wp-includes/class-wp-http-ixr-client.php | 7 ++++- tests/phpunit/tests/xmlrpc/client.php | 30 ++++++++++++++++++++ 3 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 tests/phpunit/tests/xmlrpc/client.php diff --git a/src/wp-includes/class-IXR.php b/src/wp-includes/class-IXR.php index 5a2893de6a..7264db6efb 100644 --- a/src/wp-includes/class-IXR.php +++ b/src/wp-includes/class-IXR.php @@ -629,6 +629,10 @@ class IXR_Client if (!$this->path) { $this->path = '/'; } + + if ( ! empty( $bits['query'] ) ) { + $this->path .= '?' . $bits['query']; + } } else { $this->server = $server; $this->path = $path; diff --git a/src/wp-includes/class-wp-http-ixr-client.php b/src/wp-includes/class-wp-http-ixr-client.php index 736fc5a223..b412e2a2f8 100644 --- a/src/wp-includes/class-wp-http-ixr-client.php +++ b/src/wp-includes/class-wp-http-ixr-client.php @@ -18,8 +18,13 @@ class WP_HTTP_IXR_Client extends IXR_Client { $this->path = !empty($bits['path']) ? $bits['path'] : '/'; // Make absolutely sure we have a path - if ( ! $this->path ) + if ( ! $this->path ) { $this->path = '/'; + } + + if ( ! empty( $bits['query'] ) ) { + $this->path .= '?' . $bits['query']; + } } else { $this->scheme = 'http'; $this->server = $server; diff --git a/tests/phpunit/tests/xmlrpc/client.php b/tests/phpunit/tests/xmlrpc/client.php new file mode 100644 index 0000000000..8b45017321 --- /dev/null +++ b/tests/phpunit/tests/xmlrpc/client.php @@ -0,0 +1,30 @@ +assertEquals( 'example.com', $client->server ); + $this->assertEquals( 80, $client->port ); + $this->assertEquals( '/server.php?this-is-needed=true', $client->path ); + } + + /** + * @ticket 26947 + */ + function test_wp_ixr_client_allows_query_strings() { + $client = new WP_HTTP_IXR_Client( 'http://example.com/server.php?this-is-needed=true#not-this' ); + $this->assertEquals( 'example.com', $client->server ); + $this->assertFalse( $client->port ); + $this->assertEquals( '/server.php?this-is-needed=true', $client->path ); + } +} +