File tree Expand file tree Collapse file tree 1 file changed +9
-2
lines changed
app/code/Magento/Elasticsearch8/Model/Client Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments