diff --git a/.travis.yml b/.travis.yml index 980b1b45..7ba1fce1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,11 +1,37 @@ sudo: false language: php -php: - - 5.6 - - 7.0 - - 7.1 - - 7.2 - - 7.3 + +matrix: + include: + - language: php + php: 5.6 + env: + - SYMFONY=^3.4 + + - language: php + php: 7.0 + env: + - OCRAMIUS_PACKAGE_VERSION=true + - SYMFONY=^3.4 + + - language: php + php: 7.2 + env: + - OCRAMIUS_PACKAGE_VERSION=true + - SYMFONY=^3.4 + + - language: php + php: 7.3 + env: + - OCRAMIUS_PACKAGE_VERSION=true + - SYMFONY=^4.4 + + - language: php + php: 7.4 + env: + - OCRAMIUS_PACKAGE_VERSION=true + - SYMFONY=^4.4 + env: global: - ES_VERSION=5.6.8 ES_DOWNLOAD_URL=https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-${ES_VERSION}.tar.gz @@ -16,7 +42,8 @@ install: before_script: - echo 'memory_limit=-1' >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini - composer require --no-update symfony/symfony:${SYMFONY} - - composer config -g github-oauth.github.com $GITHUB_COMPOSER_AUTH + - if [[ $OCRAMIUS_PACKAGE_VERSION = "true" ]]; then composer require ocramius/package-versions:^1.0 --no-update ;fi + - if [[ $TRAVIS_SECURE_ENV_VARS = "true" ]]; then composer config -g github-oauth.github.com $GITHUB_COMPOSER_AUTH; fi - composer install --no-interaction --prefer-dist script: diff --git a/Service/ExportService.php b/Service/ExportService.php index 5977f9c1..a3d1eb49 100644 --- a/Service/ExportService.php +++ b/Service/ExportService.php @@ -116,7 +116,7 @@ public function exportIndex( */ protected function getFilePath($filename) { - if ($filename{0} == '/' || strstr($filename, ':') !== false) { + if ($filename[0] == '/' || strstr($filename, ':') !== false) { return $filename; } diff --git a/Service/ImportService.php b/Service/ImportService.php index 0091e611..8a1d9021 100644 --- a/Service/ImportService.php +++ b/Service/ImportService.php @@ -73,7 +73,7 @@ public function importIndex( */ protected function getFilePath($filename) { - if ($filename{0} == '/' || strstr($filename, ':') !== false) { + if ($filename[0] == '/' || strstr($filename, ':') !== false) { return $filename; } diff --git a/Service/ManagerFactory.php b/Service/ManagerFactory.php index 7432bbaf..5425e10e 100644 --- a/Service/ManagerFactory.php +++ b/Service/ManagerFactory.php @@ -17,6 +17,7 @@ use ONGR\ElasticsearchBundle\Event\PreCreateManagerEvent; use ONGR\ElasticsearchBundle\Mapping\MetadataCollector; use ONGR\ElasticsearchBundle\Result\Converter; +use PackageVersions\Versions; use Psr\Log\LoggerInterface; use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Symfony\Component\Stopwatch\Stopwatch; @@ -124,6 +125,16 @@ public function createManager($managerName, $connection, $analysis, $managerConf ), ]; + if (class_exists(Versions::class)) { + $elasticSearchVersion = explode('@', Versions::getVersion('ongr/elasticsearch-dsl'))[0]; + if (0 === strpos($elasticSearchVersion, 'v')) { + $elasticSearchVersion = substr($elasticSearchVersion, 1); + } + if (version_compare($elasticSearchVersion, '7.0.0', '>=')) { + $indexSettings['include_type_name'] = true; + } + } + $this->eventDispatcher && $this->eventDispatcher->dispatch( Events::PRE_MANAGER_CREATE, diff --git a/composer.json b/composer.json index db370377..0f85512f 100644 --- a/composer.json +++ b/composer.json @@ -11,7 +11,7 @@ } ], "require": { - "php": ">=5.6,<7.4", + "php": "^5.6|^7.0", "symfony/framework-bundle": "^2.8|^3.0|^4", "symfony/console": "^2.8|^3.0|^4", "symfony/stopwatch": "^2.8|^3.0|^4", @@ -22,10 +22,10 @@ "doctrine/cache": "~1.4", "doctrine/collections": "~1.4", "monolog/monolog": "~1.10", - "elasticsearch/elasticsearch": "~5.0|~6.0", - "ongr/elasticsearch-dsl": "~5.0|~6.0" + "ongr/elasticsearch-dsl": "~5.0|~6.0|~7.0" }, "require-dev": { + "elasticsearch/elasticsearch": "~5.0|~6.0|~7.0", "mikey179/vfsstream": "~1.4", "phpunit/phpunit": "~5.6", "squizlabs/php_codesniffer": "~2.0",