Skip to content

Commit 6ad129d

Browse files
committed
Updated master with 7.x
1 parent f4b1d20 commit 6ad129d

File tree

783 files changed

+82167
-27784
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

783 files changed

+82167
-27784
lines changed

.github/workflows/test.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ jobs:
2121
uses: shivammathur/setup-php@v2
2222
with:
2323
php-version: ${{ matrix.php-version }}
24-
tools: prestissimo
2524
env:
2625
COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2726

CHANGELOG.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,43 @@
1+
# Release 7.11.0
2+
3+
- [#1089](https://github.com/elastic/elasticsearch-php/pull/1089) Added the `X-Elastic-Client-Meta` header which is used by Elastic Cloud
4+
and can be disabled with `ClientBuilder::setElasticMetaHeader(false)`
5+
- [#1075](https://github.com/elastic/elasticsearch-php/pull/1075) Replaced `array_walk` with `array_map` in `Connection::getURI` for PHP 8
6+
compatibility
7+
- [#1069](https://github.com/elastic/elasticsearch-php/pull/1069) Remove unnecessary `InvalidArgumentExceptions`
8+
- [#1063](https://github.com/elastic/elasticsearch-php/pull/1063) Introducing PHP 8 compatibility
9+
- [#1062](https://github.com/elastic/elasticsearch-php/pull/1062) Replace Sami by Doctum and fix `.gitignore`
10+
11+
## Release 7.10.0
12+
13+
- Updated endpoints and namespaces for Elasticsearch 7.10
14+
[3ceb748](https://github.com/elastic/elasticsearch-php/commit/3ceb7484a111aa20126168460c79f098c4fe0792)
15+
- Fixed ClientBuilder::fromConfig allowing multiple function
16+
parameters (e.g. setApiKey)
17+
[#1076](https://github.com/elastic/elasticsearch-php/pull/1076)
18+
- Refactored the YAML tests using generated PHPUnit code
19+
[85fadc2](https://github.com/elastic/elasticsearch-php/commit/85fadc2bd4b2b309b19761a50ff13010d43a524d)
20+
21+
## Release 7.9.1
22+
23+
- Fixed using object instead of array in onFailure transport event
24+
[#1066](https://github.com/elastic/elasticsearch-php/pull/1066)
25+
- Fixed reset custom header after endpoint call
26+
[#1065](https://github.com/elastic/elasticsearch-php/pull/1065)
27+
- Show generic error messages when server returns no response
28+
[#1056](https://github.com/elastic/elasticsearch-php/pull/1056)
29+
30+
## Release 7.9.0
31+
32+
- Updated endpoints and namespaces for Elasticsearch 7.9
33+
[28bf0ed](https://github.com/elastic/elasticsearch-php/commit/28bf0ed6df6bc95f83f369509431d97907bfdeb0)
34+
- Moved `scroll_id` into `body` for search operations in the documentation
35+
[#1052](https://github.com/elastic/elasticsearch-php/pull/1052)
36+
- Fixed PHP 7.4 preloading feature for autoload.php
37+
[#1051](https://github.com/elastic/elasticsearch-php/pull/1051)
38+
- Improved message of JSON errors using `json_last_error_msg()`
39+
[#1045](https://github.com/elastic/elasticsearch-php/pull/1045)
40+
141
## Release 7.8.0
242

343
- Updated endpoints and namespaces for Elasticsearch 7.8

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
elasticsearch-php
44
=================
55

6-
[![Build status](https://github.com/elastic/elasticsearch-php/workflows/PHP%20test/badge.svg)](https://github.com/elastic/elasticsearch-php/actions) [![Latest Stable Version](https://poser.pugx.org/elasticsearch/elasticsearch/v/stable)](https://packagist.org/packages/elasticsearch/elasticsearch) [![Total Downloads](https://poser.pugx.org/elasticsearch/elasticsearch/downloads)](https://packagist.org/packages/elasticsearch/elasticsearch)
6+
[![Build status](https://github.com/elastic/elasticsearch-php/workflows/PHP%20test/badge.svg)](https://github.com/elastic/elasticsearch-php/actions) [![Latest Stable Version](https://poser.pugx.org/elasticsearch/elasticsearch/v/stable)](https://packagist.org/packages/elasticsearch/elasticsearch) [![Total Downloads](https://poser.pugx.org/elasticsearch/elasticsearch/downloads)](https://packagist.org/packages/elasticsearch/elasticsearch)
77

88
Official low-level client for Elasticsearch. Its goal is to provide common ground for all Elasticsearch-related code in PHP; because of this it tries to be opinion-free and very extendable.
99

composer.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,6 @@
3535
"monolog/monolog": "Allows for client-level logging and tracing"
3636
},
3737
"autoload": {
38-
"files": [
39-
"src/autoload.php"
40-
],
4138
"psr-4": {
4239
"Elasticsearch\\": "src/Elasticsearch/"
4340
}

src/Elasticsearch/Client.php

Lines changed: 93 additions & 73 deletions
Large diffs are not rendered by default.

src/Elasticsearch/ClientBuilder.php

Lines changed: 37 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
use GuzzleHttp\Ring\Client\Middleware;
3939
use Psr\Log\LoggerInterface;
4040
use Psr\Log\NullLogger;
41+
use ReflectionClass;
4142

4243
class ClientBuilder
4344
{
@@ -134,7 +135,12 @@ class ClientBuilder
134135
private $sslVerification = null;
135136

136137
/**
137-
* @var bool
138+
* @var bool
139+
*/
140+
private $elasticMetaHeader = true;
141+
142+
/**
143+
* @var bool
138144
*/
139145
private $includePortInHostHeader = false;
140146

@@ -188,8 +194,14 @@ public static function fromConfig(array $config, bool $quiet = false): Client
188194
$builder = new static;
189195
foreach ($config as $key => $value) {
190196
$method = "set$key";
191-
if (method_exists($builder, $method)) {
192-
$builder->$method($value);
197+
$reflection = new ReflectionClass($builder);
198+
if ($reflection->hasMethod($method)) {
199+
$func = $reflection->getMethod($method);
200+
if ($func->getNumberOfParameters() > 1) {
201+
$builder->$method(...$value);
202+
} else {
203+
$builder->$method($value);
204+
}
193205
unset($config[$key]);
194206
}
195207
}
@@ -337,7 +349,6 @@ public function setHosts(array $hosts): ClientBuilder
337349
/**
338350
* Set the APIKey Pair, consiting of the API Id and the ApiKey of the Response from /_security/api_key
339351
*
340-
*
341352
* @throws AuthenticationConfigException
342353
*/
343354
public function setApiKey(string $id, string $apiKey): ClientBuilder
@@ -382,19 +393,20 @@ public function setBasicAuthentication(string $username, string $password): Clie
382393
/**
383394
* Set Elastic Cloud ID to connect to Elastic Cloud
384395
*
385-
*
386396
* @param string $cloudId
387397
*/
388398
public function setElasticCloudId(string $cloudId): ClientBuilder
389399
{
390400
// Register the Hosts array
391-
$this->setHosts([
401+
$this->setHosts(
402+
[
392403
[
393404
'host' => $this->parseElasticCloudId($cloudId),
394405
'port' => '',
395406
'scheme' => 'https',
396407
]
397-
]);
408+
]
409+
);
398410

399411
if (!isset($this->connectionParams['client']['curl'][CURLOPT_ENCODING])) {
400412
// Merge best practices for the connection (enable gzip)
@@ -456,7 +468,7 @@ public function setSSLKey(string $key, string $password = null): ClientBuilder
456468
}
457469

458470
/**
459-
* @param bool|string $value
471+
* @param bool|string $value
460472
*/
461473
public function setSSLVerification($value = true): ClientBuilder
462474
{
@@ -465,8 +477,19 @@ public function setSSLVerification($value = true): ClientBuilder
465477
return $this;
466478
}
467479

480+
/**
481+
* Set or disable the x-elastic-client-meta header
482+
*/
483+
public function setElasticMetaHeader($value = true): ClientBuilder
484+
{
485+
$this->elasticMetaHeader = $value;
486+
487+
return $this;
488+
}
489+
468490
/**
469491
* Include the port in Host header
492+
*
470493
* @see https://github.com/elastic/elasticsearch-php/issues/993
471494
*/
472495
public function includePortInHostHeader(bool $enable): ClientBuilder
@@ -516,6 +539,7 @@ public function build(): Client
516539
$this->serializer = new $this->serializer;
517540
}
518541

542+
$this->connectionParams['client']['x-elastic-client-meta']= $this->elasticMetaHeader;
519543
$this->connectionParams['client']['port_in_header'] = $this->includePortInHostHeader;
520544

521545
if (is_null($this->connectionFactory)) {
@@ -555,7 +579,11 @@ public function build(): Client
555579

556580
$this->endpoint = function ($class) use ($serializer) {
557581
$fullPath = '\\Elasticsearch\\Endpoints\\' . $class;
558-
if ($class === 'Bulk' || $class === 'Msearch' || $class === 'MsearchTemplate' || $class === 'MPercolate') {
582+
583+
$reflection = new ReflectionClass($fullPath);
584+
$constructor = $reflection->getConstructor();
585+
586+
if ($constructor && $constructor->getParameters()) {
559587
return new $fullPath($serializer);
560588
} else {
561589
return new $fullPath();

src/Elasticsearch/Common/EmptyLogger.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
*
2727
* Logger that doesn't do anything. Similar to Monolog's NullHandler,
2828
* but avoids the overhead of partially loading Monolog
29-
*
3029
*/
3130
class EmptyLogger extends AbstractLogger implements LoggerInterface
3231
{

src/Elasticsearch/Common/Exceptions/BadMethodCallException.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
* See the LICENSE file in the project root for more information.
1414
*/
1515

16+
1617
declare(strict_types = 1);
1718

1819
namespace Elasticsearch\Common\Exceptions;
@@ -21,7 +22,6 @@
2122
* BadMethodCallException
2223
*
2324
* Denote problems with a method call (e.g. incorrect number of arguments)
24-
*
2525
*/
2626
class BadMethodCallException extends \BadMethodCallException implements ElasticsearchException
2727
{

src/Elasticsearch/Common/Exceptions/BadRequest400Exception.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,6 @@
1818

1919
namespace Elasticsearch\Common\Exceptions;
2020

21-
/**
22-
* BadRequest400Exception, thrown on 400 conflict http error
23-
*
24-
*/
2521
class BadRequest400Exception extends \Exception implements ElasticsearchException
2622
{
2723
}

src/Elasticsearch/Common/Exceptions/Serializer/JsonErrorException.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@
2020

2121
use Elasticsearch\Common\Exceptions\ElasticsearchException;
2222

23+
/**
24+
* Class JsonErrorException
25+
*/
2326
class JsonErrorException extends \Exception implements ElasticsearchException
2427
{
2528
/**

0 commit comments

Comments
 (0)