Skip to content

Fix/6.7 #884

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 29, 2019
Merged
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
14 changes: 8 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,32 +29,34 @@ Version Matrix

| Elasticsearch Version | Elasticsearch-PHP Branch |
| --------------------- | ------------------------ |
| >= 6.0, < 7.0 | 6.0 |
| >= 6.6, < 7.0 | 6.7.x |
| >= 6.0, < 6.6 | 6.5.x |
| >= 5.0, < 6.0 | 5.0 |
| >= 2.0, < 5.0 | 1.0 or 2.0 |
| >= 1.0, < 2.0 | 1.0 or 2.0 |
| <= 0.90.x | 0.4 |

- If you are using Elasticsearch 6.x, use Elasticsearch-PHP 6.0 branch.
- If you are using Elasticsearch 6.6 to 6.7, use Elasticsearch-PHP 6.7.x branch.
- If you are using Elasticsearch 6.0 to 6.5, use Elasticsearch-PHP 6.5.x branch.
- If you are using Elasticsearch 5.x, use Elasticsearch-PHP 5.0 branch.
- 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.
- 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.
- 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.

Documentation
--------------
[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!
[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!

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

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):
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):

```json
{
"require": {
"elasticsearch/elasticsearch": "^6.5"
"elasticsearch/elasticsearch": "^6.7"
}
}
```
Expand Down Expand Up @@ -353,7 +355,7 @@ That was just a crash-course overview of the client and its syntax. If you are

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.

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.
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.


Available Licenses
Expand Down
5 changes: 3 additions & 2 deletions docs/installation.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ The master branch will always track Elasticsearch master, but it is not recommen
[width="40%",options="header",frame="topbot"]
|============================
|Elasticsearch Version | Elasticsearch-PHP Branch
| >= 6.0 | `6.0`
| >= 6.6, <= 6.7 | `6.7`
| >= 6.0, <= 6.5 | `6.5`
| >= 5.0, <= 6.0 | `5.0`
| >= 1.0, <= 5.0 | `1.0`, `2.0`
| <= 0.90.* | `0.4`
Expand All @@ -41,7 +42,7 @@ The master branch will always track Elasticsearch master, but it is not recommen
--------------------------
{
"require": {
"elasticsearch/elasticsearch": "~6.0"
"elasticsearch/elasticsearch": "~6.7.0"
}
}
--------------------------
Expand Down
3 changes: 2 additions & 1 deletion src/Elasticsearch/Endpoints/Bulk.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@ public function getParamWhitelist()
'_source_includes',
'_source_exclude',
'_source_excludes',
'pipeline'
'pipeline',
'seq_no_primary_term'
);
}

Expand Down
3 changes: 3 additions & 0 deletions src/Elasticsearch/Endpoints/Delete.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ public function getParamWhitelist()
'timeout',
'version',
'version_type',
'include_type_name',
'if_primary_term',
'if_seq_no'
);
}

Expand Down
3 changes: 2 additions & 1 deletion src/Elasticsearch/Endpoints/Get.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,8 @@ public function getParamWhitelist()
'_source_excludes',
'version',
'version_type',
'stored_fields'
'stored_fields',
'include_type_name'
);
}

Expand Down
3 changes: 2 additions & 1 deletion src/Elasticsearch/Endpoints/Index.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,8 @@ public function getParamWhitelist()
'version_type',
'pipeline',
'if_primary_term',
'if_seq_no'
'if_seq_no',
'include_type_name'
);
}

Expand Down
3 changes: 2 additions & 1 deletion src/Elasticsearch/Endpoints/Indices/Create.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ public function getParamWhitelist()
'timeout',
'master_timeout',
'update_all_types',
'wait_for_active_shards'
'wait_for_active_shards',
'include_type_name'
);
}

Expand Down
2 changes: 1 addition & 1 deletion src/Elasticsearch/Endpoints/Indices/Field/Get.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public function getParamWhitelist()
'ignore_unavailable',
'allow_no_indices',
'expand_wildcards',
'local',
'local'
);
}

Expand Down
3 changes: 2 additions & 1 deletion src/Elasticsearch/Endpoints/Indices/Get.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ public function getParamWhitelist()
'ignore_unavailable',
'allow_no_indices',
'expand_wildcards',
'human'
'human',
'include_type_name'
);
}

Expand Down
1 change: 1 addition & 0 deletions src/Elasticsearch/Endpoints/Indices/Mapping/Get.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ public function getParamWhitelist()
'expand_wildcards',
'wildcard_expansion',
'local',
'include_type_name'
);
}

Expand Down
3 changes: 2 additions & 1 deletion src/Elasticsearch/Endpoints/Indices/Mapping/GetField.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ public function getParamWhitelist()
'ignore_unavailable',
'allow_no_indices',
'expand_wildcards',
'local'
'local',
'include_type_name'
);
}

Expand Down
25 changes: 14 additions & 11 deletions src/Elasticsearch/Endpoints/Indices/Mapping/Put.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,19 +41,21 @@ public function setBody($body)
*/
public function getURI()
{
if (isset($this->type) !== true) {
$index = $this->index ?? null;
$type = $this->type ?? null;

if (null === $index && $type === $index) {
throw new Exceptions\RuntimeException(
'type is required for Put'
'type or index are required for Put'
);
}
$index = $this->index;
$type = $this->type;
$uri = "/_mapping/$type";

if (isset($index) === true && isset($type) === true) {
$uri = "/$index/$type/_mapping";
} elseif (isset($type) === true) {
$uri = "/_mapping/$type";
$uri = '';
if (null !== $index) {
$uri = "/$index";
}
$uri .= '/_mapping';
if (null !== $type) {
$uri .= "/$type";
}

return $uri;
Expand All @@ -71,7 +73,8 @@ public function getParamWhitelist()
'ignore_unavailable',
'allow_no_indices',
'expand_wildcards',
'update_all_types'
'update_all_types',
'include_type_name'
);
}

Expand Down
1 change: 1 addition & 0 deletions src/Elasticsearch/Endpoints/Indices/Rollover.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ public function getParamWhitelist()
'timeout',
'master_timeout',
'wait_for_active_shards',
'include_type_name'
);
}

Expand Down
3 changes: 2 additions & 1 deletion src/Elasticsearch/Endpoints/Indices/Template/Get.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ public function getParamWhitelist()
return array(
'flat_settings',
'local',
'master_timeout'
'master_timeout',
'include_type_name'
);
}

Expand Down
3 changes: 2 additions & 1 deletion src/Elasticsearch/Endpoints/Indices/Template/Put.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,8 @@ public function getParamWhitelist()
'timeout',
'master_timeout',
'flat_settings',
'create'
'create',
'include_type_name'
);
}

Expand Down
3 changes: 2 additions & 1 deletion src/Elasticsearch/Endpoints/Search.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,8 @@ public function getParamWhitelist()
'batched_reduce_size',
'typed_keys',
'pre_filter_shard_size',
'rest_total_hits_as_int'
'rest_total_hits_as_int',
'seq_no_primary_term'
);
}

Expand Down
5 changes: 4 additions & 1 deletion src/Elasticsearch/Endpoints/Update.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,10 @@ public function getParamWhitelist()
'ttl',
'version',
'version_type',
'_source'
'_source',
'include_type_name',
'if_primary_term',
'if_seq_no'
);
}

Expand Down
26 changes: 23 additions & 3 deletions tests/Elasticsearch/Tests/YamlRunnerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,17 @@ class YamlRunnerTest extends \PHPUnit\Framework\TestCase
private static $skippedTests = [
'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',
'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\'',
'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] '
'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] ',
];

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

/**
* @var SplFileInfo $file
*/
* @var SplFileInfo $file
*/
foreach ($finder as $file) {
$files = array_merge($files, $this->splitDocument($file, $path, $filter));
}
Expand Down Expand Up @@ -944,6 +952,7 @@ private function formatRegex(string $regex): string
*/
private function splitDocument(SplFileInfo $file, string $path, string $filter = null): array
{

$fileContent = $file->getContents();
// cleanup some bad comments
$fileContent = str_replace('"#', '" #', $fileContent);
Expand Down Expand Up @@ -973,6 +982,17 @@ function ($item) {
$skip = false;
$documentParsed = null;
foreach ($documents as $documentString) {
// Extract test name
if (preg_match('/"([^"]+)"/', $documentString, $matches)) {
$testName = $matches[1];
// Skip YAML parsing if test is signed to be skipped and if PHP is < version specified
// To prevent YAML parse error, e.g. empty property
if (array_key_exists("$fileName#$testName", static::$skippedTestsIfPhpLessThan)) {
if (version_compare(PHP_VERSION, static::$skippedTestsIfPhpLessThan["$fileName#$testName"], '<')) {
continue;
}
}
}
// TODO few bad instances of teardown, should be fixed in upstream but this is a quick fix locally
$documentString = str_replace(" teardown:", "teardown:", $documentString);
try {
Expand Down