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(
83
83
/**
84
84
* Get Elasticsearch 8 Client
85
85
*
86
- * @return Client
86
+ * @return Client|null
87
87
*/
88
- private function getElasticsearchClient (): Client /** @phpstan-ignore-line */
88
+ private function getElasticsearchClient (): ? Client /** @phpstan-ignore-line */
89
89
{
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
+
90
96
$ pid = getmypid ();
91
97
if (!isset ($ this ->client [$ pid ])) {
92
98
$ config = $ this ->buildESConfig ($ this ->clientOptions );
93
99
if (class_exists (\Elastic \Elasticsearch \ClientBuilder::class)) {
94
100
$ this ->client [$ pid ] = ClientBuilder::fromConfig ($ config , true ); /** @phpstan-ignore-line */
95
101
}
96
102
}
103
+
97
104
return $ this ->client [$ pid ];
98
105
}
99
106
You can’t perform that action at this time.
0 commit comments