Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 4 additions & 7 deletions app/code/Magento/Elasticsearch8/Model/Client/Elasticsearch.php
Original file line number Diff line number Diff line change
Expand Up @@ -196,12 +196,9 @@ public function indexExists(string $index): bool
private function buildESConfig(array $options = []): array
{
$hostname = preg_replace('/http[s]?:\/\//i', '', $options['hostname']);
// @codingStandardsIgnoreStart
$protocol = parse_url($options['hostname'], PHP_URL_SCHEME);
// @codingStandardsIgnoreEnd
if (!$protocol) {
$protocol = 'http';
}
$url = parse_url($options['hostname']);

$options['scheme'] = $url['scheme'] ?? 'http';

$authString = '';
if (!empty($options['enableAuth']) && (int)$options['enableAuth'] === 1) {
Expand All @@ -213,7 +210,7 @@ private function buildESConfig(array $options = []): array
$portString = ':' . $options['port'];
}

$host = $protocol . '://' . $authString . $hostname . $portString;
$host = ($options['scheme'] ?? 'http') . '://' . $authString . $hostname . $portString;

$options['hosts'] = [$host];

Expand Down
11 changes: 4 additions & 7 deletions app/code/Magento/OpenSearch/Model/SearchClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,12 +137,9 @@ public function testConnection(): bool
private function buildOSConfig(array $options = []): array
{
$hostname = preg_replace('/http[s]?:\/\//i', '', $options['hostname']);
// @codingStandardsIgnoreStart
$protocol = parse_url($options['hostname'], PHP_URL_SCHEME);
// @codingStandardsIgnoreEnd
if (!$protocol) {
$protocol = 'http';
}
$url = parse_url($options['hostname']);

$options['scheme'] = $url['scheme'] ?? 'http';

$authString = '';
if (!empty($options['enableAuth']) && (int)$options['enableAuth'] === 1) {
Expand All @@ -154,7 +151,7 @@ private function buildOSConfig(array $options = []): array
$portString = ':' . $options['port'];
}

$host = $protocol . '://' . $authString . $hostname . $portString;
$host = ($options['scheme'] ?? 'http') . '://' . $authString . $hostname . $portString;

$options['hosts'] = [$host];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,9 @@ public function isValidConnection(array $options)
private function buildConfig(array $options)
{
$hostname = preg_replace('/http[s]?:\/\//i', '', $options['hostname']);
// @codingStandardsIgnoreStart
$protocol = parse_url($options['hostname'], PHP_URL_SCHEME);
// @codingStandardsIgnoreEnd
if (!$protocol) {
$protocol = 'http';
}
$url = parse_url($options['hostname']);

$options['scheme'] = $url['scheme'] ?? 'http';

$authString = '';
if (isset($options['enableAuth']) && true === $options['enableAuth']) {
Expand All @@ -59,7 +56,7 @@ private function buildConfig(array $options)
$authString = "{$options['username']}:{$options['password']}@";
}
$portString = empty($options['port']) ? '' : ':' . $options['port'];
$host = $protocol . '://' . $authString . $hostname . $portString;
$host = ($options['scheme'] ?? 'http') . '://' . $authString . $hostname . $portString;
$options['hosts'] = [$host];

return $options;
Expand Down