New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
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
Conflict between timeout option of Connection::ping and ClientBuilder::connectionParams #561
Comments
JMLamodiere
added a commit
to JMLamodiere/elasticsearch-php
that referenced
this issue
Apr 3, 2017
JMLamodiere
added a commit
to JMLamodiere/elasticsearch-php
that referenced
this issue
Apr 3, 2017
Oh, PHP. :( Thanks for this! Kinda amazed it's taken me/the client this long to stumble into this particular bug |
polyfractal
pushed a commit
that referenced
this issue
Apr 12, 2017
polyfractal
pushed a commit
that referenced
this issue
Apr 12, 2017
polyfractal
pushed a commit
that referenced
this issue
Apr 12, 2017
I cherry-picked to 5.0 branch as well :) |
p365labs
pushed a commit
to p365labs/elasticsearch-php
that referenced
this issue
Sep 10, 2017
p365labs
pushed a commit
to p365labs/elasticsearch-php
that referenced
this issue
Sep 10, 2017
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Summary of problem or feature request
TL;DR
To merge a multi-dimensionnal array with defaults defined in another, as done in Connection::performRequest, we should use array-replace-recursive instead of array-merge-recursive. Here is a runnable snippet
The bug
There is a bug when merging
timeout
param with a connection pool other than the default one (StaticNoPingConnectionPool
) and when a globaltimeout
is defined at connection level.People affected
Those using another ConnectionPool that the default one (
StaticNoPingConnectionPool
) AND defining atimeout
at connection level.Description
PR #507 has added the ability to set defaults params at connection level instead of per request, such as
$params['client']['timeout']
The method Connection::ping() will also set a client
timeout
to 1. This methodping
is not called when using the default connection pool (StaticNoPingConnectionPool
), but is used with others, such asStaticConnectionPool
.When
timeout
is set in those 2 places, the method Connection::performRequest will merge them with array_merge_recursive. But this php function as a weird behaviour : instead of overriding this integer param, it replace it with an array containing the 2 values.It will result in a bug when GuzzleHttp\Ring\Client\CurlFactory::applyHandlerOptions tries to multiply this value *1000 : the value contains an array instead of an integer and cannot be multiplied.
We should use array_replace_recursive instead
Code snippet of problem
Here is a runnable snippet
At the first request :
The $value contains
array (0 => 5, 1 => 1)
(both timeouts) whereas it should contain an integer (one of the timeouts).System details
The text was updated successfully, but these errors were encountered: