From f0c79f38cf4d3b2a7097500bbc0bebe3b5619b67 Mon Sep 17 00:00:00 2001 From: Ryan Cramer Date: Tue, 16 Apr 2019 06:08:52 -0400 Subject: [PATCH] Additional update for processwire/processwire-issues#849 --- wire/core/WireHttp.php | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/wire/core/WireHttp.php b/wire/core/WireHttp.php index 859b3f2f..a198436e 100644 --- a/wire/core/WireHttp.php +++ b/wire/core/WireHttp.php @@ -516,10 +516,11 @@ class WireHttp extends Wire { $this->error[] = 'CURL is not available'; return false; } else if(!$allowCURL) { - $this->error[] = 'Using CURL requires PHP 5.6+'; + $this->error[] = 'Using CURL requires PHP 5.5+'; return false; + } else { + return $this->sendCURL($url, $method, $options); } - return $this->sendCURL($url, $method, $options); } else if($options['use'] === 'fopen' && !$allowFopen) { $this->error[] = 'fopen is not available'; @@ -638,8 +639,16 @@ class WireHttp extends Wire { curl_setopt($curl, CURLOPT_TIMEOUT, $timeout); curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); - curl_setopt($curl, CURLOPT_SAFE_UPLOAD, true); curl_setopt($curl, CURLOPT_USERAGENT, $this->getUserAgent()); + + if(version_compare(PHP_VERSION, '5.6') >= 0) { + // CURLOPT_SAFE_UPLOAD value is default true (setopt not necessary) + // and PHP 7+ removes this option + } else if(version_compare(PHP_VERSION, '5.5') >= 0) { + curl_setopt($curl, CURLOPT_SAFE_UPLOAD, true); + } else { + // not reachable: version blocked before sendCURL call + } if(count($this->headers)) { curl_setopt($curl, CURLOPT_HTTPHEADER, $this->headers);