Skip to content

Commit 3113b49

Browse files
committed
connector upgrade
1 parent 34956b0 commit 3113b49

File tree

2 files changed

+26
-13
lines changed

2 files changed

+26
-13
lines changed

composer.json

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,24 @@
2323
"illuminate/container": "^8.0",
2424
"illuminate/database": "^8.0",
2525
"illuminate/events": "^8.0",
26-
"elasticsearch/elasticsearch": "8.10"
26+
"elasticsearch/elasticsearch": "^8.10"
27+
},
28+
"require-dev": {
29+
"phpunit/phpunit": "^9.5.8",
30+
"orchestra/testbench": "^7.19",
31+
"mockery/mockery": "^1.3.1",
32+
"doctrine/dbal": "^2.13.3|^3.1.4"
2733
},
28-
"require-dev": {},
2934
"autoload": {
3035
"psr-4": {
3136
"PDPhilip\\Elasticsearch\\": "src/"
3237
}
3338
},
39+
"autoload-dev": {
40+
"psr-4": {
41+
"PDPhilip\\Elasticsearch\\Tests\\": "tests/"
42+
}
43+
},
3444
"extra": {
3545
"laravel": {
3646
"providers": [

src/Connection.php

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@ class Connection extends BaseConnection
1717
protected $index;
1818
protected $maxSize;
1919
protected $indexPrefix;
20-
protected $retires = null; //null will use default
20+
protected $allowIdSort = false;
2121
protected $sslVerification = true;
22-
protected $elasticMetaHeader = true;
22+
protected $retires = null; //null will use default
23+
protected $elasticMetaHeader = null;
2324
protected $rebuild = false;
24-
protected $allowIdSort = false;
2525

2626
public function __construct(array $config)
2727
{
@@ -44,21 +44,21 @@ public function setOptions($config)
4444
if (!empty($config['index_prefix'])) {
4545
$this->indexPrefix = $config['index_prefix'];
4646
}
47-
if (!empty($config['options']['allow_id_sort'])) {
47+
if (isset($config['options']['allow_id_sort'])) {
4848
$this->allowIdSort = $config['options']['allow_id_sort'];
4949
}
50-
if (!empty($config['options']['ssl_verification'])) {
50+
if (isset($config['options']['ssl_verification'])) {
5151
$this->sslVerification = $config['options']['ssl_verification'];
5252
}
53-
if (!empty($config['options']['retires'])) {
53+
if (isset($config['options']['retires'])) {
5454
$this->retires = $config['options']['retires'];
5555
}
56-
if (!empty($config['options']['meta_header'])) {
56+
if (isset($config['options']['meta_header'])) {
5757
$this->elasticMetaHeader = $config['options']['meta_header'];
5858
}
5959
}
6060

61-
public function getIndexPrefix(): string|null
61+
public function getIndexPrefix()
6262
{
6363
return $this->indexPrefix;
6464
}
@@ -69,7 +69,7 @@ public function setIndexPrefix($newPrefix): void
6969
}
7070

7171

72-
public function getTablePrefix(): string|null
72+
public function getTablePrefix()
7373
{
7474
return $this->getIndexPrefix();
7575
}
@@ -239,8 +239,11 @@ protected function _cloudConnection(): Client
239239
protected function _builderOptions($cb)
240240
{
241241
$cb->setSSLVerification($this->sslVerification);
242-
$cb->setElasticMetaHeader($this->elasticMetaHeader);
243-
if ($this->retires) {
242+
if (isset($this->elasticMetaHeader)) {
243+
$cb->setElasticMetaHeader($this->elasticMetaHeader);
244+
}
245+
246+
if (isset($this->retires)) {
244247
$cb->setRetries($this->retires);
245248
}
246249
$caBundle = config('database.connections.elasticsearch.ssl_cert') ?? null;

0 commit comments

Comments
 (0)