From 616df59b322e45e5129900c8a8326be3aff55045 Mon Sep 17 00:00:00 2001 From: Aaron Schulz Date: Thu, 9 Jan 2014 13:38:55 -0800 Subject: [PATCH] Fixed http_build_query warnings on PHP < 5.4 * bug: 59880 Change-Id: I2eae4bed17a72b58ac33f3538dd7d16f4356a3a0 --- includes/libs/MultiHttpClient.php | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/includes/libs/MultiHttpClient.php b/includes/libs/MultiHttpClient.php index 29f737e4d9..0675b38d38 100644 --- a/includes/libs/MultiHttpClient.php +++ b/includes/libs/MultiHttpClient.php @@ -6,11 +6,13 @@ * HTTP request maps use the following format: * - method : GET/HEAD/PUT/POST/DELETE * - url : HTTP/HTTPS URL - * - query : + * - query : (uses RFC 3986) * - headers :
* - body : source to get the HTTP request body from; * this can simply be a string (always), a resource for - * PUT requests, and a field/value array for POST request + * PUT requests, and a field/value array for POST request; + * array bodies are encoded as multipart/form-data and strings + * use application/x-www-form-urlencoded (headers sent automatically) * - stream : resource to stream the HTTP response body to * * @author Aaron Schulz @@ -179,7 +181,12 @@ class MultiHttpClient { curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 ); $url = $req['url']; - $query = http_build_query( $req['query'], '', '&', PHP_QUERY_RFC3986 ); + // PHP_QUERY_RFC3986 is PHP 5.4+ only + $query = str_replace( + array( '+', '%7E' ), + array( '%20', '~' ), + http_build_query( $req['query'], '', '&' ) + ); if ( $query != '' ) { $url .= strpos( $req['url'], '?' ) === false ? "?$query" : "&$query"; } -- 2.20.1