-
-
Notifications
You must be signed in to change notification settings - Fork 239
fix: correct service parameters for elastic_search
type handlers
#501
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
Conversation
@@ -292,7 +292,7 @@ private function buildHandler(ContainerBuilder $container, $name, array $handler | ||
$factory = class_exists('Elastic\Elasticsearch\ClientBuilder') ? 'Elastic\Elasticsearch\ClientBuilder' : 'Elasticsearch\ClientBuilder'; | ||
$client->setFactory([$factory, 'fromConfig']); | ||
$clientArguments = [ | ||
'host' => $handler['elasticsearch']['host'], | ||
'hosts' => [$handler['elasticsearch']['host']], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not valid. The arguments need to be different for V7 or v8 (see just above where we already detect version 8+ for other differences)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Like I said in the ticket, this applies to both v7 and v8. ClientBuilder::fromConfig
works the same in both versions by proxying to the set*
method and the only such method that exists is setHosts
, not setHost
.
In my demo project I just ran composer require elasticsearch/elasticsearch=^7
(using Elastica, so no v8), then set the monolog config like:
monolog:
handlers:
main:
type: fingers_crossed
handler: elastic_search
action_level: error
excluded_http_codes: [404, 405]
buffer_size: 50
elastic_search:
type: elastic_search
elasticsearch:
host: '%elastic_domain%'
port: '%elastic_port%'
index: '%elastic_index_monolog%'
Finally, I ran ./bin/console cache:clear
(after rm -rf var/cache/*
for good measure). And it also fails with:
In ClientBuilder.php line 217:
Unknown parameters provided: host
So far as I can tell this has always been the case in that client (though I only checked to v5). I think we just accidentally assumed the parameter was the same as Elastica at the time of implementation.
You are correct when it comes to Elastica, though, which I noted here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@stof Bump!
(Let me know if y'all don't like bumps.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking at the method ClientBuilder::fromConfig
of all versions of elasticsearch-php, I see that the parameter has always been the plural hosts
. This update looks good to me.
The PR needs to be rebased on 3.x.
a9be50c
to
e70641d
Compare
e70641d
to
cae1fb8
Compare
Thanks for fixing this bug @Kenneth-Sills. |
Closes #500