Skip to content

Commit e8d2d3a

Browse files
committed
AC-7116: Fixed DBC test failures
1 parent 1fbbd45 commit e8d2d3a

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

app/code/Magento/Elasticsearch8/Model/Client/Elasticsearch.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,17 +83,24 @@ public function __construct(
8383
/**
8484
* Get Elasticsearch 8 Client
8585
*
86-
* @return Client
86+
* @return Client|null
8787
*/
88-
private function getElasticsearchClient(): Client /** @phpstan-ignore-line */
88+
private function getElasticsearchClient(): ?Client /** @phpstan-ignore-line */
8989
{
90+
// Intentionally added condition as there are BC changes from ES7 to ES8
91+
// and by default ES7 is configured.
92+
if (!class_exists(\Elastic\Elasticsearch\Client::class)) {
93+
return null;
94+
}
95+
9096
$pid = getmypid();
9197
if (!isset($this->client[$pid])) {
9298
$config = $this->buildESConfig($this->clientOptions);
9399
if (class_exists(\Elastic\Elasticsearch\ClientBuilder::class)) {
94100
$this->client[$pid] = ClientBuilder::fromConfig($config, true); /** @phpstan-ignore-line */
95101
}
96102
}
103+
97104
return $this->client[$pid];
98105
}
99106

0 commit comments

Comments
 (0)