Skip to content

Commit f42ae00

Browse files
alexander-schranztooonisaimaz
authored
Add support for es7 in version 5 (ongr-io#909)
* Add support for es7 in version 5 * Fix travis CI error * Replaced curly braces for array access Co-authored-by: Toni Rudolf <[email protected]> Co-authored-by: Simonas Šerlinskas <[email protected]>
1 parent c6d5bc7 commit f42ae00

File tree

5 files changed

+50
-12
lines changed

5 files changed

+50
-12
lines changed

.travis.yml

Lines changed: 34 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,37 @@
11
sudo: false
22
language: php
3-
php:
4-
- 5.6
5-
- 7.0
6-
- 7.1
7-
- 7.2
8-
- 7.3
3+
4+
matrix:
5+
include:
6+
- language: php
7+
php: 5.6
8+
env:
9+
- SYMFONY=^3.4
10+
11+
- language: php
12+
php: 7.0
13+
env:
14+
- OCRAMIUS_PACKAGE_VERSION=true
15+
- SYMFONY=^3.4
16+
17+
- language: php
18+
php: 7.2
19+
env:
20+
- OCRAMIUS_PACKAGE_VERSION=true
21+
- SYMFONY=^3.4
22+
23+
- language: php
24+
php: 7.3
25+
env:
26+
- OCRAMIUS_PACKAGE_VERSION=true
27+
- SYMFONY=^4.4
28+
29+
- language: php
30+
php: 7.4
31+
env:
32+
- OCRAMIUS_PACKAGE_VERSION=true
33+
- SYMFONY=^4.4
34+
935
env:
1036
global:
1137
- ES_VERSION=5.6.8 ES_DOWNLOAD_URL=https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-${ES_VERSION}.tar.gz
@@ -16,7 +42,8 @@ install:
1642
before_script:
1743
- echo 'memory_limit=-1' >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini
1844
- composer require --no-update symfony/symfony:${SYMFONY}
19-
- composer config -g github-oauth.github.com $GITHUB_COMPOSER_AUTH
45+
- if [[ $OCRAMIUS_PACKAGE_VERSION = "true" ]]; then composer require ocramius/package-versions:^1.0 --no-update ;fi
46+
- if [[ $TRAVIS_SECURE_ENV_VARS = "true" ]]; then composer config -g github-oauth.github.com $GITHUB_COMPOSER_AUTH; fi
2047
- composer install --no-interaction --prefer-dist
2148

2249
script:

Service/ExportService.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ public function exportIndex(
116116
*/
117117
protected function getFilePath($filename)
118118
{
119-
if ($filename{0} == '/' || strstr($filename, ':') !== false) {
119+
if ($filename[0] == '/' || strstr($filename, ':') !== false) {
120120
return $filename;
121121
}
122122

Service/ImportService.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ public function importIndex(
7373
*/
7474
protected function getFilePath($filename)
7575
{
76-
if ($filename{0} == '/' || strstr($filename, ':') !== false) {
76+
if ($filename[0] == '/' || strstr($filename, ':') !== false) {
7777
return $filename;
7878
}
7979

Service/ManagerFactory.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
use ONGR\ElasticsearchBundle\Event\PreCreateManagerEvent;
1818
use ONGR\ElasticsearchBundle\Mapping\MetadataCollector;
1919
use ONGR\ElasticsearchBundle\Result\Converter;
20+
use PackageVersions\Versions;
2021
use Psr\Log\LoggerInterface;
2122
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
2223
use Symfony\Component\Stopwatch\Stopwatch;
@@ -124,6 +125,16 @@ public function createManager($managerName, $connection, $analysis, $managerConf
124125
),
125126
];
126127

128+
if (class_exists(Versions::class)) {
129+
$elasticSearchVersion = explode('@', Versions::getVersion('ongr/elasticsearch-dsl'))[0];
130+
if (0 === strpos($elasticSearchVersion, 'v')) {
131+
$elasticSearchVersion = substr($elasticSearchVersion, 1);
132+
}
133+
if (version_compare($elasticSearchVersion, '7.0.0', '>=')) {
134+
$indexSettings['include_type_name'] = true;
135+
}
136+
}
137+
127138
$this->eventDispatcher &&
128139
$this->eventDispatcher->dispatch(
129140
Events::PRE_MANAGER_CREATE,

composer.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
}
1212
],
1313
"require": {
14-
"php": ">=5.6,<7.4",
14+
"php": "^5.6|^7.0",
1515
"symfony/framework-bundle": "^2.8|^3.0|^4",
1616
"symfony/console": "^2.8|^3.0|^4",
1717
"symfony/stopwatch": "^2.8|^3.0|^4",
@@ -22,10 +22,10 @@
2222
"doctrine/cache": "~1.4",
2323
"doctrine/collections": "~1.4",
2424
"monolog/monolog": "~1.10",
25-
"elasticsearch/elasticsearch": "~5.0|~6.0",
26-
"ongr/elasticsearch-dsl": "~5.0|~6.0"
25+
"ongr/elasticsearch-dsl": "~5.0|~6.0|~7.0"
2726
},
2827
"require-dev": {
28+
"elasticsearch/elasticsearch": "~5.0|~6.0|~7.0",
2929
"mikey179/vfsstream": "~1.4",
3030
"phpunit/phpunit": "~5.6",
3131
"squizlabs/php_codesniffer": "~2.0",

0 commit comments

Comments
 (0)