Skip to content

Commit 1a3d6a5

Browse files
authored
Merge pull request #884 from ezimuel/fix/6.7
Fix/6.7
2 parents 0661e83 + 5a1782d commit 1a3d6a5

File tree

18 files changed

+76
-33
lines changed

18 files changed

+76
-33
lines changed

README.md

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,32 +29,34 @@ Version Matrix
2929

3030
| Elasticsearch Version | Elasticsearch-PHP Branch |
3131
| --------------------- | ------------------------ |
32-
| >= 6.0, < 7.0 | 6.0 |
32+
| >= 6.6, < 7.0 | 6.7.x |
33+
| >= 6.0, < 6.6 | 6.5.x |
3334
| >= 5.0, < 6.0 | 5.0 |
3435
| >= 2.0, < 5.0 | 1.0 or 2.0 |
3536
| >= 1.0, < 2.0 | 1.0 or 2.0 |
3637
| <= 0.90.x | 0.4 |
3738

38-
- If you are using Elasticsearch 6.x, use Elasticsearch-PHP 6.0 branch.
39+
- If you are using Elasticsearch 6.6 to 6.7, use Elasticsearch-PHP 6.7.x branch.
40+
- If you are using Elasticsearch 6.0 to 6.5, use Elasticsearch-PHP 6.5.x branch.
3941
- If you are using Elasticsearch 5.x, use Elasticsearch-PHP 5.0 branch.
4042
- If you are using Elasticsearch 1.x or 2.x, prefer using the Elasticsearch-PHP 2.0 branch. The 1.0 branch is compatible however.
4143
- If you are using a version older than 1.0, you must install the `0.4` Elasticsearch-PHP branch. Since ES 0.90.x and below is now EOL, the corresponding `0.4` branch will not receive any more development or bugfixes. Please upgrade.
4244
- You should never use Elasticsearch-PHP Master branch, as it tracks Elasticsearch master and may contain incomplete features or breaks in backwards compatibility. Only use ES-PHP master if you are developing against ES master for some reason.
4345

4446
Documentation
4547
--------------
46-
[Full documentation can be found here.](https://www.elastic.co/guide/en/elasticsearch/client/php-api/6.0/index.html) Docs are stored within the repo under /docs/, so if you see a typo or problem, please submit a PR to fix it!
48+
[Full documentation can be found here.](https://www.elastic.co/guide/en/elasticsearch/client/php-api/current/index.html) Docs are stored within the repo under /docs/, so if you see a typo or problem, please submit a PR to fix it!
4749

4850
Installation via Composer
4951
-------------------------
5052
The recommended method to install _Elasticsearch-PHP_ is through [Composer](http://getcomposer.org).
5153

52-
1. Add `elasticsearch/elasticsearch` as a dependency in your project's `composer.json` file (change version to suit your version of Elasticsearch, for instance this is for ES 6.0 to 6.5):
54+
1. Add `elasticsearch/elasticsearch` as a dependency in your project's `composer.json` file (change version to suit your version of Elasticsearch, for instance for ES 6.7):
5355

5456
```json
5557
{
5658
"require": {
57-
"elasticsearch/elasticsearch": "^6.5"
59+
"elasticsearch/elasticsearch": "^6.7"
5860
}
5961
}
6062
```
@@ -353,7 +355,7 @@ That was just a crash-course overview of the client and its syntax. If you are
353355

354356
You'll also notice that the client is configured in a manner that facilitates easy discovery via the IDE. All core actions are available under the `$client` object (indexing, searching, getting, etc.). Index and cluster management are located under the `$client->indices()` and `$client->cluster()` objects, respectively.
355357

356-
Check out the rest of the [Documentation](https://www.elastic.co/guide/en/elasticsearch/client/php-api/6.0/index.html) to see how the entire client works.
358+
Check out the rest of the [Documentation](https://www.elastic.co/guide/en/elasticsearch/client/php-api/current/index.html) to see how the entire client works.
357359

358360

359361
Available Licenses

docs/installation.asciidoc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ The master branch will always track Elasticsearch master, but it is not recommen
2727
[width="40%",options="header",frame="topbot"]
2828
|============================
2929
|Elasticsearch Version | Elasticsearch-PHP Branch
30-
| >= 6.0 | `6.0`
30+
| >= 6.6, <= 6.7 | `6.7`
31+
| >= 6.0, <= 6.5 | `6.5`
3132
| >= 5.0, <= 6.0 | `5.0`
3233
| >= 1.0, <= 5.0 | `1.0`, `2.0`
3334
| <= 0.90.* | `0.4`
@@ -41,7 +42,7 @@ The master branch will always track Elasticsearch master, but it is not recommen
4142
--------------------------
4243
{
4344
"require": {
44-
"elasticsearch/elasticsearch": "~6.0"
45+
"elasticsearch/elasticsearch": "~6.7.0"
4546
}
4647
}
4748
--------------------------

src/Elasticsearch/Endpoints/Bulk.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,8 @@ public function getParamWhitelist()
7878
'_source_includes',
7979
'_source_exclude',
8080
'_source_excludes',
81-
'pipeline'
81+
'pipeline',
82+
'seq_no_primary_term'
8283
);
8384
}
8485

src/Elasticsearch/Endpoints/Delete.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,9 @@ public function getParamWhitelist()
6464
'timeout',
6565
'version',
6666
'version_type',
67+
'include_type_name',
68+
'if_primary_term',
69+
'if_seq_no'
6770
);
6871
}
6972

src/Elasticsearch/Endpoints/Get.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,8 @@ public function getParamWhitelist()
9999
'_source_excludes',
100100
'version',
101101
'version_type',
102-
'stored_fields'
102+
'stored_fields',
103+
'include_type_name'
103104
);
104105
}
105106

src/Elasticsearch/Endpoints/Index.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,8 @@ public function getParamWhitelist()
9696
'version_type',
9797
'pipeline',
9898
'if_primary_term',
99-
'if_seq_no'
99+
'if_seq_no',
100+
'include_type_name'
100101
);
101102
}
102103

src/Elasticsearch/Endpoints/Indices/Create.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,8 @@ public function getParamWhitelist()
6565
'timeout',
6666
'master_timeout',
6767
'update_all_types',
68-
'wait_for_active_shards'
68+
'wait_for_active_shards',
69+
'include_type_name'
6970
);
7071
}
7172

src/Elasticsearch/Endpoints/Indices/Field/Get.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ public function getParamWhitelist()
8080
'ignore_unavailable',
8181
'allow_no_indices',
8282
'expand_wildcards',
83-
'local',
83+
'local'
8484
);
8585
}
8686

src/Elasticsearch/Endpoints/Indices/Get.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,8 @@ public function getParamWhitelist()
6767
'ignore_unavailable',
6868
'allow_no_indices',
6969
'expand_wildcards',
70-
'human'
70+
'human',
71+
'include_type_name'
7172
);
7273
}
7374

src/Elasticsearch/Endpoints/Indices/Mapping/Get.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ public function getParamWhitelist()
4848
'expand_wildcards',
4949
'wildcard_expansion',
5050
'local',
51+
'include_type_name'
5152
);
5253
}
5354

src/Elasticsearch/Endpoints/Indices/Mapping/GetField.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,8 @@ public function getParamWhitelist()
6767
'ignore_unavailable',
6868
'allow_no_indices',
6969
'expand_wildcards',
70-
'local'
70+
'local',
71+
'include_type_name'
7172
);
7273
}
7374

src/Elasticsearch/Endpoints/Indices/Mapping/Put.php

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -41,19 +41,21 @@ public function setBody($body)
4141
*/
4242
public function getURI()
4343
{
44-
if (isset($this->type) !== true) {
44+
$index = $this->index ?? null;
45+
$type = $this->type ?? null;
46+
47+
if (null === $index && $type === $index) {
4548
throw new Exceptions\RuntimeException(
46-
'type is required for Put'
49+
'type or index are required for Put'
4750
);
4851
}
49-
$index = $this->index;
50-
$type = $this->type;
51-
$uri = "/_mapping/$type";
52-
53-
if (isset($index) === true && isset($type) === true) {
54-
$uri = "/$index/$type/_mapping";
55-
} elseif (isset($type) === true) {
56-
$uri = "/_mapping/$type";
52+
$uri = '';
53+
if (null !== $index) {
54+
$uri = "/$index";
55+
}
56+
$uri .= '/_mapping';
57+
if (null !== $type) {
58+
$uri .= "/$type";
5759
}
5860

5961
return $uri;
@@ -71,7 +73,8 @@ public function getParamWhitelist()
7173
'ignore_unavailable',
7274
'allow_no_indices',
7375
'expand_wildcards',
74-
'update_all_types'
76+
'update_all_types',
77+
'include_type_name'
7578
);
7679
}
7780

src/Elasticsearch/Endpoints/Indices/Rollover.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ public function getParamWhitelist()
9898
'timeout',
9999
'master_timeout',
100100
'wait_for_active_shards',
101+
'include_type_name'
101102
);
102103
}
103104

src/Elasticsearch/Endpoints/Indices/Template/Get.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,8 @@ public function getParamWhitelist()
6565
return array(
6666
'flat_settings',
6767
'local',
68-
'master_timeout'
68+
'master_timeout',
69+
'include_type_name'
6970
);
7071
}
7172

src/Elasticsearch/Endpoints/Indices/Template/Put.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,8 @@ public function getParamWhitelist()
8989
'timeout',
9090
'master_timeout',
9191
'flat_settings',
92-
'create'
92+
'create',
93+
'include_type_name'
9394
);
9495
}
9596

src/Elasticsearch/Endpoints/Search.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,8 @@ public function getParamWhitelist()
104104
'batched_reduce_size',
105105
'typed_keys',
106106
'pre_filter_shard_size',
107-
'rest_total_hits_as_int'
107+
'rest_total_hits_as_int',
108+
'seq_no_primary_term'
108109
);
109110
}
110111

src/Elasticsearch/Endpoints/Update.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,10 @@ public function getParamWhitelist()
8787
'ttl',
8888
'version',
8989
'version_type',
90-
'_source'
90+
'_source',
91+
'include_type_name',
92+
'if_primary_term',
93+
'if_seq_no'
9194
);
9295
}
9396

tests/Elasticsearch/Tests/YamlRunnerTest.php

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,17 @@ class YamlRunnerTest extends \PHPUnit\Framework\TestCase
6868
private static $skippedTests = [
6969
'nodes.stats/30_discovery.yml#Discovery stats' => 'Failing on ES 6.1+: nodes.$master.discovery is an empty array, expected to have cluster_state_queue field in it',
7070
'indices.stats/20_translog.yml#Translog retention' => 'Failing on ES 6.3+: Failed asserting that 495 is equal to <string:$creation_size> or is less than \'$creation_size\'',
71-
'indices.shrink/30_copy_settings.yml#Copy settings during shrink index' => 'Failing on ES 6.4+: Failed to match in test "Copy settings during shrink index". Expected [\'4\'] does not match [false] '
71+
'indices.shrink/30_copy_settings.yml#Copy settings during shrink index' => 'Failing on ES 6.4+: Failed to match in test "Copy settings during shrink index". Expected [\'4\'] does not match [false] ',
7272
];
7373

74+
private static $skippedTestsIfPhpLessThan = [
75+
// Failing on ES 6.7+ only with PHP 7.0: Cannot access empty property
76+
'indices.put_mapping/11_basic_with_types.yml#Create index with invalid mappings' => '7.1.0',
77+
'indices.put_mapping/10_basic.yml#Create index with invalid mappings' => '7.1.0',
78+
'indices.create/11_basic_with_types.yml#Create index with invalid mappings' => '7.1.0',
79+
'indices.create/11_basic_with_types.yml#Create index with no type mappings' => '7.1.0',
80+
'indices.create/10_basic.yml#Create index with invalid mappings' => '7.1.0',
81+
];
7482
/**
7583
* @var array A list of skipped test with their reasons
7684
*/
@@ -814,8 +822,8 @@ public function yamlProvider(): array
814822
$filter = getenv('TEST_CASE') !== false ? getenv('TEST_CASE') : null;
815823

816824
/**
817-
* @var SplFileInfo $file
818-
*/
825+
* @var SplFileInfo $file
826+
*/
819827
foreach ($finder as $file) {
820828
$files = array_merge($files, $this->splitDocument($file, $path, $filter));
821829
}
@@ -944,6 +952,7 @@ private function formatRegex(string $regex): string
944952
*/
945953
private function splitDocument(SplFileInfo $file, string $path, string $filter = null): array
946954
{
955+
947956
$fileContent = $file->getContents();
948957
// cleanup some bad comments
949958
$fileContent = str_replace('"#', '" #', $fileContent);
@@ -973,6 +982,17 @@ function ($item) {
973982
$skip = false;
974983
$documentParsed = null;
975984
foreach ($documents as $documentString) {
985+
// Extract test name
986+
if (preg_match('/"([^"]+)"/', $documentString, $matches)) {
987+
$testName = $matches[1];
988+
// Skip YAML parsing if test is signed to be skipped and if PHP is < version specified
989+
// To prevent YAML parse error, e.g. empty property
990+
if (array_key_exists("$fileName#$testName", static::$skippedTestsIfPhpLessThan)) {
991+
if (version_compare(PHP_VERSION, static::$skippedTestsIfPhpLessThan["$fileName#$testName"], '<')) {
992+
continue;
993+
}
994+
}
995+
}
976996
// TODO few bad instances of teardown, should be fixed in upstream but this is a quick fix locally
977997
$documentString = str_replace(" teardown:", "teardown:", $documentString);
978998
try {

0 commit comments

Comments
 (0)