Skip to content

Commit 0ed0147

Browse files
committed
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
1 parent 8355232 commit 0ed0147

3 files changed

Lines changed: 40 additions & 1 deletion

File tree

src/wp-includes/class-IXR.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -629,6 +629,10 @@ function IXR_Client($server, $path = false, $port = 80, $timeout = 15)
629629
if (!$this->path) {
630630
$this->path = '/';
631631
}
632+
633+
if ( ! empty( $bits['query'] ) ) {
634+
$this->path .= '?' . $bits['query'];
635+
}
632636
} else {
633637
$this->server = $server;
634638
$this->path = $path;

src/wp-includes/class-wp-http-ixr-client.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,13 @@ function __construct($server, $path = false, $port = false, $timeout = 15) {
1818
$this->path = !empty($bits['path']) ? $bits['path'] : '/';
1919

2020
// Make absolutely sure we have a path
21-
if ( ! $this->path )
21+
if ( ! $this->path ) {
2222
$this->path = '/';
23+
}
24+
25+
if ( ! empty( $bits['query'] ) ) {
26+
$this->path .= '?' . $bits['query'];
27+
}
2328
} else {
2429
$this->scheme = 'http';
2530
$this->server = $server;
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?php
2+
require_once ABSPATH . WPINC . '/class-IXR.php';
3+
require_once ABSPATH . WPINC . '/class-wp-http-ixr-client.php';
4+
5+
/**
6+
* @group xmlrpc
7+
*/
8+
class Tests_XMLRPC_Client extends WP_XMLRPC_UnitTestCase {
9+
10+
/**
11+
* @ticket 26947
12+
*/
13+
function test_ixr_client_allows_query_strings() {
14+
$client = new IXR_Client( 'http://example.com/server.php?this-is-needed=true#not-this' );
15+
$this->assertEquals( 'example.com', $client->server );
16+
$this->assertEquals( 80, $client->port );
17+
$this->assertEquals( '/server.php?this-is-needed=true', $client->path );
18+
}
19+
20+
/**
21+
* @ticket 26947
22+
*/
23+
function test_wp_ixr_client_allows_query_strings() {
24+
$client = new WP_HTTP_IXR_Client( 'http://example.com/server.php?this-is-needed=true#not-this' );
25+
$this->assertEquals( 'example.com', $client->server );
26+
$this->assertFalse( $client->port );
27+
$this->assertEquals( '/server.php?this-is-needed=true', $client->path );
28+
}
29+
}
30+

0 commit comments

Comments
 (0)