BUG: Correct semantic error regarding cURL options in RestfulService

cURL options are numeric, and array_merge is destructive of numeric
keys. Replace array_merge calls with array union operator, with defaults
on right-hand side so that passed options override defaults.
This commit is contained in:
Fred Condo 2013-02-22 17:39:01 -08:00
parent 8a70019e78
commit bd73142bcf

View File

@ -140,7 +140,7 @@ class RestfulService extends ViewableData {
$method, $method,
$data, $data,
array_merge((array)$this->customHeaders, (array)$headers), array_merge((array)$this->customHeaders, (array)$headers),
array_merge(self::$default_curl_options,$curlOptions), $curlOptions + self::$default_curl_options,
$this->getBasicAuthString() $this->getBasicAuthString()
)); ));
@ -196,7 +196,7 @@ class RestfulService extends ViewableData {
$timeout = 5; $timeout = 5;
$sapphireInfo = new SapphireInfo(); $sapphireInfo = new SapphireInfo();
$useragent = 'SilverStripe/' . $sapphireInfo->Version(); $useragent = 'SilverStripe/' . $sapphireInfo->Version();
$curlOptions = array_merge(self::$default_curl_options, $curlOptions); $curlOptions = $curlOptions + self::$default_curl_options;
curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);