添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement . We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

This might be a weird request, but if anyone could help, I would be grateful.

I am getting the following error:

Warning: curl_setopt_array(): Array keys must be CURLOPT constants or equivalent integer values in /home/storage/d/1d/59/planofunerariofamili/public_html/vendor/guzzlehttp/guzzle/src/Handler/CurlFactory.php on line 57

I know this is because I am using a cURL version that is from August 2006, almost 10 years old. The version is curl-7.15.5-17.el5_9 .

The problem is, I am running on a shared server, on a host provider called LOCAWEB. I am trying to get LOCAWEB to upgrade the cURL version, but this might take a long while. I just have so much stuff hosted with them that I am dreading having to move to another provider.

So, can anyone help me fix CurlFactory.php (and any other files involved)? In order to remove this problem so that guzzle can run in curl-7.15.5-17.el5_9 ?

NOTE: I have tried to comment out the CURLOPT_PROTOCOLS (since it was only implemented in cURL 7.19) but it did not fix the problem.

//if (defined('CURLOPT_PROTOCOLS')) { //$conf[CURLOPT_PROTOCOLS] = CURLPROTO_HTTP | CURLPROTO_HTTPS; //}

Anyone can please help me with this backward compatibility problem?

OK, I figured it out after quite a long night.

Here is the problem:

CURLOPT_TIMEOUT_MS: Added in cURL 7.16.2. Available since PHP 5.2.3.

Since my server is using version curl-7.15.5 , the cURL could not resolve the CURLOPT_TIMEOUT_MS.

To solve this, in CurlFactory.php , right before curl_setopt_array($easy->handle, $conf); in the public function create(RequestInterface $request, array $options) I inserted the following php code:

foreach($conf as $key => $item) { if (strpos($key, 'CURLOPT_TIMEOUT_MS') !== false) { unset($conf[$key]); $conf[CURLOPT_TIMEOUT] = 60; } }

Substituting CURLOPT_TIMEOUT_MS for CURLOPT_TIMEOUT solved the situation, since CURLOPT_TIMEOUT is from the first implementation.

I know this is not an elegant solution, ideally I should check the curl version and change the variable accordingly when it is first set. But in this case I will leave it to the developers.

ADDITIONAL NOTE: There are a few other variables that might break the code in older servers. Check here http://php.net/manual/pt_BR/function.curl-setopt.php if you are using any of these and compare with your server implementation of cURL with rpm -aq | grep curl or the dpkg equivalente shell command.

Guzzle requires cURL 7.19.4 or greater. I don't plan on reducing this requirement, but thanks for documenting how others who might also run into this issue can move forward. I would suggest updating cURL on your system.

http://docs.guzzlephp.org/en/latest/overview.html#requirements