From 3d15e991de99d8caec73133704b3c8ee5800f5c8 Mon Sep 17 00:00:00 2001 From: Frank Klein Koerkamp Date: Wed, 19 Apr 2017 17:23:09 +0200 Subject: [PATCH 01/29] Changed all deprecated methods + changed composer dependency --- Content/ArticleDataProvider.php | 6 +++--- Content/ArticleSelectionContentType.php | 4 ++-- Controller/ArticleController.php | 12 ++++++------ Document/Index/ArticleIndexer.php | 6 +++--- Markup/ArticleLinkProvider.php | 12 +++++++----- Sitemap/ArticleSitemapProvider.php | 8 ++++---- Teaser/ArticleTeaserProvider.php | 4 ++-- .../Unit/Content/ArticleSelectionContentTypeTest.php | 4 ++-- Tests/app/config/config.yml | 11 ++++------- composer.json | 2 +- 10 files changed, 34 insertions(+), 35 deletions(-) diff --git a/Content/ArticleDataProvider.php b/Content/ArticleDataProvider.php index e07aa61be..bdbcb2ace 100644 --- a/Content/ArticleDataProvider.php +++ b/Content/ArticleDataProvider.php @@ -13,9 +13,9 @@ use ONGR\ElasticsearchBundle\Result\DocumentIterator; use ONGR\ElasticsearchBundle\Service\Manager; -use ONGR\ElasticsearchDSL\Query\BoolQuery; +use ONGR\ElasticsearchDSL\Query\Compound\BoolQuery; use ONGR\ElasticsearchDSL\Query\MatchAllQuery; -use ONGR\ElasticsearchDSL\Query\TermQuery; +use ONGR\ElasticsearchDSL\Query\TermLevel\TermQuery; use ONGR\ElasticsearchDSL\Search; use ONGR\ElasticsearchDSL\Sort\FieldSort; use ProxyManager\Factory\LazyLoadingValueHolderFactory; @@ -249,7 +249,7 @@ private function getSearchResult(array $filters, $limit, $page, $pageSize, $loca $this->appendSortBy($filters['sortBy'], $sortMethod, $search); } - return $repository->execute($search); + return $repository->findDocuments($search); } /** diff --git a/Content/ArticleSelectionContentType.php b/Content/ArticleSelectionContentType.php index a0a58da1e..d8bff1b93 100644 --- a/Content/ArticleSelectionContentType.php +++ b/Content/ArticleSelectionContentType.php @@ -12,7 +12,7 @@ namespace Sulu\Bundle\ArticleBundle\Content; use ONGR\ElasticsearchBundle\Service\Manager; -use ONGR\ElasticsearchDSL\Query\IdsQuery; +use ONGR\ElasticsearchDSL\Query\TermLevel\IdsQuery; use Sulu\Bundle\ArticleBundle\Document\ArticleViewDocumentInterface; use Sulu\Bundle\ArticleBundle\Metadata\ArticleViewDocumentIdTrait; use Sulu\Component\Content\Compat\PropertyInterface; @@ -72,7 +72,7 @@ public function getContentData(PropertyInterface $property) $result = []; /** @var ArticleViewDocumentInterface $articleDocument */ - foreach ($repository->execute($search) as $articleDocument) { + foreach ($repository->findDocuments($search) as $articleDocument) { $result[array_search($articleDocument->getUuid(), $value, false)] = $articleDocument; } diff --git a/Controller/ArticleController.php b/Controller/ArticleController.php index 499e18db4..1c65f7fc6 100644 --- a/Controller/ArticleController.php +++ b/Controller/ArticleController.php @@ -15,12 +15,12 @@ use FOS\RestBundle\Routing\ClassResourceInterface; use JMS\Serializer\SerializationContext; use ONGR\ElasticsearchBundle\Service\Manager; -use ONGR\ElasticsearchDSL\Query\BoolQuery; -use ONGR\ElasticsearchDSL\Query\IdsQuery; +use ONGR\ElasticsearchDSL\Query\Compound\BoolQuery; +use ONGR\ElasticsearchDSL\Query\TermLevel\IdsQuery; use ONGR\ElasticsearchDSL\Query\MatchAllQuery; -use ONGR\ElasticsearchDSL\Query\MatchQuery; -use ONGR\ElasticsearchDSL\Query\MultiMatchQuery; -use ONGR\ElasticsearchDSL\Query\TermQuery; +use ONGR\ElasticsearchDSL\Query\FullText\MatchQuery; +use ONGR\ElasticsearchDSL\Query\FullText\MultiMatchQuery; +use ONGR\ElasticsearchDSL\Query\TermLevel\TermQuery; use ONGR\ElasticsearchDSL\Sort\FieldSort; use Sulu\Bundle\ArticleBundle\Admin\ArticleAdmin; use Sulu\Bundle\ArticleBundle\Document\Form\ArticleDocumentType; @@ -149,7 +149,7 @@ public function cgetAction(Request $request) $search->setFrom(($page - 1) * $limit); $result = []; - foreach ($repository->execute($search) as $document) { + foreach ($repository->findDocuments($search) as $document) { if (false !== ($index = array_search($document->getUuid(), $ids))) { $result[$index] = $document; } else { diff --git a/Document/Index/ArticleIndexer.php b/Document/Index/ArticleIndexer.php index 6c29298bc..5bd682a71 100644 --- a/Document/Index/ArticleIndexer.php +++ b/Document/Index/ArticleIndexer.php @@ -13,7 +13,7 @@ use ONGR\ElasticsearchBundle\Service\Manager; use ONGR\ElasticsearchDSL\Query\MatchAllQuery; -use ONGR\ElasticsearchDSL\Query\TermQuery; +use ONGR\ElasticsearchDSL\Query\TermLevel\TermQuery; use Sulu\Bundle\ArticleBundle\Document\ArticleDocument; use Sulu\Bundle\ArticleBundle\Document\ArticleViewDocument; use Sulu\Bundle\ArticleBundle\Document\ArticleViewDocumentInterface; @@ -254,7 +254,7 @@ public function remove($document) $search = $repository->createSearch() ->addQuery(new TermQuery('uuid', $document->getUuid())) ->setSize(1000); - foreach ($repository->execute($search) as $viewDocument) { + foreach ($repository->findDocuments($search) as $viewDocument) { $this->manager->remove($viewDocument); } } @@ -279,7 +279,7 @@ public function clear() ->setSize($pageSize); do { - $result = $repository->execute($search); + $result = $repository->findDocuments($search); foreach ($result as $document) { $this->manager->remove($document); } diff --git a/Markup/ArticleLinkProvider.php b/Markup/ArticleLinkProvider.php index 4f87ff26e..a051ab08d 100644 --- a/Markup/ArticleLinkProvider.php +++ b/Markup/ArticleLinkProvider.php @@ -12,8 +12,9 @@ namespace Sulu\Bundle\ArticleBundle\Markup; use ONGR\ElasticsearchBundle\Service\Manager; -use ONGR\ElasticsearchDSL\Query\IdsQuery; -use ONGR\ElasticsearchDSL\Query\RangeQuery; +use ONGR\ElasticsearchBundle\Service\Repository; +use ONGR\ElasticsearchDSL\Query\TermLevel\IdsQuery; +use ONGR\ElasticsearchDSL\Query\TermLevel\RangeQuery; use ONGR\ElasticsearchDSL\Search; use Sulu\Bundle\ArticleBundle\Document\ArticleViewDocumentInterface; use Sulu\Bundle\ArticleBundle\Document\Index\DocumentFactory; @@ -27,7 +28,7 @@ class ArticleLinkProvider implements LinkProviderInterface { /** - * @var Manager + * @var Repository */ private $manager; @@ -46,7 +47,7 @@ class ArticleLinkProvider implements LinkProviderInterface * @param DocumentFactory $documentFactory * @param array $types */ - public function __construct(Manager $manager, DocumentFactory $documentFactory, array $types) + public function __construct(Repository $manager, DocumentFactory $documentFactory, array $types) { $this->manager = $manager; $this->documentFactory = $documentFactory; @@ -87,7 +88,8 @@ public function preload(array $hrefs, $locale, $published = true) $search->addQuery(new RangeQuery('authored', ['lte' => 'now'])); } - $documents = $this->manager->execute([$this->documentFactory->getClass('article')], $search); + $repository = $this->manager->getRepository($this->documentFactory->getClass('article')); + $documents = $repository->findDocuments($search); $result = []; /** @var ArticleViewDocumentInterface $document */ diff --git a/Sitemap/ArticleSitemapProvider.php b/Sitemap/ArticleSitemapProvider.php index b35ed2d27..979e115fa 100644 --- a/Sitemap/ArticleSitemapProvider.php +++ b/Sitemap/ArticleSitemapProvider.php @@ -13,7 +13,7 @@ use ONGR\ElasticsearchBundle\Service\Manager; use ONGR\ElasticsearchBundle\Service\Repository; -use ONGR\ElasticsearchDSL\Query\TermQuery; +use ONGR\ElasticsearchDSL\Query\TermLevel\TermQuery; use Sulu\Bundle\ArticleBundle\Document\ArticleViewDocumentInterface; use Sulu\Bundle\ArticleBundle\Document\Index\DocumentFactoryInterface; use Sulu\Bundle\WebsiteBundle\Sitemap\Sitemap; @@ -72,11 +72,11 @@ public function build($page, $portalKey, $locale) private function getBulk(Repository $repository, $from, $size) { $search = $repository->createSearch() - ->addQuery(new TermQuery('seo.hide_in_sitemap', false)) + ->addQuery(new TermQuery('seo.hide_in_sitemap', 'false')) ->setFrom($from) ->setSize($size); - return $repository->execute($search); + return $repository->findDocuments($search); } /** @@ -94,7 +94,7 @@ public function getMaxPage() { $repository = $this->manager->getRepository($this->documentFactory->getClass('article')); $search = $repository->createSearch() - ->addQuery(new TermQuery('seo.hide_in_sitemap', false)); + ->addQuery(new TermQuery('seo.hide_in_sitemap', 'false')); return ceil($repository->count($search) / self::PAGE_SIZE); } diff --git a/Teaser/ArticleTeaserProvider.php b/Teaser/ArticleTeaserProvider.php index 35fbaa34a..c1c39ffcf 100644 --- a/Teaser/ArticleTeaserProvider.php +++ b/Teaser/ArticleTeaserProvider.php @@ -12,7 +12,7 @@ namespace Sulu\Bundle\ArticleBundle\Teaser; use ONGR\ElasticsearchBundle\Service\Manager; -use ONGR\ElasticsearchDSL\Query\IdsQuery; +use ONGR\ElasticsearchDSL\Query\TermLevel\IdsQuery; use Sulu\Bundle\ArticleBundle\Metadata\ArticleViewDocumentIdTrait; use Sulu\Bundle\ContentBundle\Teaser\Configuration\TeaserConfiguration; use Sulu\Bundle\ContentBundle\Teaser\Provider\TeaserProviderInterface; @@ -88,7 +88,7 @@ public function find(array $ids, $locale) $search->addQuery(new IdsQuery($articleIds)); $result = []; - foreach ($repository->execute($search) as $item) { + foreach ($repository->findDocuments($search) as $item) { $excerpt = $item->getExcerpt(); $result[] = new Teaser( $item->getUuid(), diff --git a/Tests/Unit/Content/ArticleSelectionContentTypeTest.php b/Tests/Unit/Content/ArticleSelectionContentTypeTest.php index f3f134494..0db0e2bd3 100644 --- a/Tests/Unit/Content/ArticleSelectionContentTypeTest.php +++ b/Tests/Unit/Content/ArticleSelectionContentTypeTest.php @@ -13,7 +13,7 @@ use ONGR\ElasticsearchBundle\Service\Manager; use ONGR\ElasticsearchBundle\Service\Repository; -use ONGR\ElasticsearchDSL\Query\IdsQuery; +use ONGR\ElasticsearchDSL\Query\TermLevel\IdsQuery; use ONGR\ElasticsearchDSL\Search; use Prophecy\Argument; use Sulu\Bundle\ArticleBundle\Content\ArticleSelectionContentType; @@ -64,7 +64,7 @@ function ($id) { } ) )->shouldBeCalled(); - $repository->execute($search->reveal())->willReturn($articles); + $repository->findDocuments($search->reveal())->willReturn($articles); $contentType = new ArticleSelectionContentType( $manager->reveal(), diff --git a/Tests/app/config/config.yml b/Tests/app/config/config.yml index 2001fcbcd..efb095c14 100644 --- a/Tests/app/config/config.yml +++ b/Tests/app/config/config.yml @@ -14,18 +14,15 @@ sulu_core: type: "article" ongr_elasticsearch: - connections: - default: - index_name: su_articles_test - live: - index_name: su_articles_test_live managers: default: - connection: default + index: + index_name: su_articles_test mappings: - SuluArticleBundle live: - connection: live + index: + index_name: su_articles_test_live mappings: - SuluArticleBundle # Sulu Routing diff --git a/composer.json b/composer.json index 2900afb2b..338cae031 100644 --- a/composer.json +++ b/composer.json @@ -6,7 +6,7 @@ "require": { "php": "^5.5 || ^7.0", "sulu/sulu": "^1.5.3 || dev-develop", - "ongr/elasticsearch-bundle": "~1.0" + "ongr/elasticsearch-bundle": "~1.0 || ~5.0" }, "require-dev": { "zendframework/zend-stdlib": "2.3.1 as 2.0.0rc5", From 6377f5251ac35385bbe3d342ebe14453fd9654df Mon Sep 17 00:00:00 2001 From: Frank Klein Koerkamp Date: Wed, 19 Apr 2017 17:26:30 +0200 Subject: [PATCH 02/29] Fixed Repository -> Manager --- Markup/ArticleLinkProvider.php | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/Markup/ArticleLinkProvider.php b/Markup/ArticleLinkProvider.php index a051ab08d..9e7f12e4b 100644 --- a/Markup/ArticleLinkProvider.php +++ b/Markup/ArticleLinkProvider.php @@ -12,7 +12,6 @@ namespace Sulu\Bundle\ArticleBundle\Markup; use ONGR\ElasticsearchBundle\Service\Manager; -use ONGR\ElasticsearchBundle\Service\Repository; use ONGR\ElasticsearchDSL\Query\TermLevel\IdsQuery; use ONGR\ElasticsearchDSL\Query\TermLevel\RangeQuery; use ONGR\ElasticsearchDSL\Search; @@ -28,7 +27,7 @@ class ArticleLinkProvider implements LinkProviderInterface { /** - * @var Repository + * @var Manager */ private $manager; @@ -43,11 +42,11 @@ class ArticleLinkProvider implements LinkProviderInterface private $types; /** - * @param Manager $manager + * @param Manager $manager * @param DocumentFactory $documentFactory - * @param array $types + * @param array $types */ - public function __construct(Repository $manager, DocumentFactory $documentFactory, array $types) + public function __construct(Manager $manager, DocumentFactory $documentFactory, array $types) { $this->manager = $manager; $this->documentFactory = $documentFactory; From 01f5e61b297e03eb5d602c0c8dbb8a097cda6d82 Mon Sep 17 00:00:00 2001 From: Frank Klein Koerkamp Date: Wed, 19 Apr 2017 17:31:07 +0200 Subject: [PATCH 03/29] Documentation update for ES 5. --- Resources/doc/installation.md | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/Resources/doc/installation.md b/Resources/doc/installation.md index e45942ed1..59ae70861 100644 --- a/Resources/doc/installation.md +++ b/Resources/doc/installation.md @@ -42,18 +42,15 @@ sulu_core: type: "article" ongr_elasticsearch: - connections: - default: - index_name: su_articles - live: - index_name: su_articles_live managers: default: - connection: default + index: + index_name: su_articles mappings: - SuluArticleBundle live: - connection: live + index: + index_name: su_articles_live mappings: - SuluArticleBundle ``` From 04667c2aad737cf4b5f22bb7a12a18c3f7a18d16 Mon Sep 17 00:00:00 2001 From: Frank Klein Koerkamp Date: Wed, 19 Apr 2017 18:49:36 +0200 Subject: [PATCH 04/29] Code style fix --- Controller/ArticleController.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Controller/ArticleController.php b/Controller/ArticleController.php index 1c65f7fc6..54680a74a 100644 --- a/Controller/ArticleController.php +++ b/Controller/ArticleController.php @@ -16,10 +16,10 @@ use JMS\Serializer\SerializationContext; use ONGR\ElasticsearchBundle\Service\Manager; use ONGR\ElasticsearchDSL\Query\Compound\BoolQuery; -use ONGR\ElasticsearchDSL\Query\TermLevel\IdsQuery; -use ONGR\ElasticsearchDSL\Query\MatchAllQuery; use ONGR\ElasticsearchDSL\Query\FullText\MatchQuery; use ONGR\ElasticsearchDSL\Query\FullText\MultiMatchQuery; +use ONGR\ElasticsearchDSL\Query\MatchAllQuery; +use ONGR\ElasticsearchDSL\Query\TermLevel\IdsQuery; use ONGR\ElasticsearchDSL\Query\TermLevel\TermQuery; use ONGR\ElasticsearchDSL\Sort\FieldSort; use Sulu\Bundle\ArticleBundle\Admin\ArticleAdmin; @@ -180,7 +180,7 @@ public function cgetAction(Request $request) /** * Returns single article. * - * @param string $uuid + * @param string $uuid * @param Request $request * * @return Response @@ -233,7 +233,7 @@ public function postAction(Request $request) * Update articles. * * @param Request $request - * @param string $uuid + * @param string $uuid * * @return Response */ @@ -308,7 +308,7 @@ public function deleteAction($id) * * @Post("/articles/{uuid}") * - * @param string $uuid + * @param string $uuid * @param Request $request * * @return Response @@ -343,7 +343,7 @@ public function postTriggerAction($uuid, Request $request) $data = $this->getMapper()->copyLanguage($uuid, $userId, null, $locale, explode(',', $destLocales)); break; default: - throw new RestException('Unrecognized action: ' . $action); + throw new RestException('Unrecognized action: '.$action); } // prepare view @@ -367,7 +367,7 @@ public function getSecurityContext() /** * Persists the document using the given information. * - * @param array $data + * @param array $data * @param object $document * @param string $locale * From 49b927d21cbdb6035e7b75a81965384f726b5307 Mon Sep 17 00:00:00 2001 From: Frank Klein Koerkamp Date: Thu, 20 Apr 2017 08:56:47 +0200 Subject: [PATCH 05/29] Now testcase also working for other ES version --- Tests/app/AppKernel.php | 9 ++++++-- Tests/app/config/config_es2.yml | 37 +++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+), 2 deletions(-) create mode 100644 Tests/app/config/config_es2.yml diff --git a/Tests/app/AppKernel.php b/Tests/app/AppKernel.php index 187d7e308..3be28399f 100644 --- a/Tests/app/AppKernel.php +++ b/Tests/app/AppKernel.php @@ -35,9 +35,14 @@ public function registerContainerConfiguration(LoaderInterface $loader) parent::registerContainerConfiguration($loader); if (getenv('SYMFONY__PHPCR__TRANSPORT') === 'jackrabbit') { - $loader->load(__DIR__ . '/config/versioning.yml'); + $loader->load(__DIR__.'/config/versioning.yml'); } - $loader->load(__DIR__ . '/config/config.yml'); + // If version is lower then 5.6 it is an testcase for elasticsearch 2.*, so different ONGR config is needed + if (phpversion() < 5.6) { + $loader->load(__DIR__.'/config/config_es2.yml'); + } else { + $loader->load(__DIR__.'/config/config.yml'); + } } } diff --git a/Tests/app/config/config_es2.yml b/Tests/app/config/config_es2.yml new file mode 100644 index 000000000..53140eefb --- /dev/null +++ b/Tests/app/config/config_es2.yml @@ -0,0 +1,37 @@ +# Doctrine Configuration +doctrine: + dbal: + dbname: "su_articles_test" + +sulu_core: + content: + structure: + default_type: + article: "default" + paths: + article: + path: "%kernel.root_dir%/Resources/articles" + type: "article" + +ongr_elasticsearch: + connections: + default: + index_name: su_articles_test + live: + index_name: su_articles_test_live + managers: + default: + connection: default + mappings: + - SuluArticleBundle + live: + connection: live + mappings: + - SuluArticleBundle +# Sulu Routing +sulu_route: + mappings: + Sulu\Bundle\ArticleBundle\Document\ArticleDocument: + generator: schema + options: + route_schema: /articles/{object.getTitle()} \ No newline at end of file From 070c8a78daac8721db46ed02dcb94e63114f4b69 Mon Sep 17 00:00:00 2001 From: Frank Klein Koerkamp Date: Thu, 20 Apr 2017 09:10:54 +0200 Subject: [PATCH 06/29] Codestyle fixes --- Controller/ArticleController.php | 2 +- Tests/app/AppKernel.php | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Controller/ArticleController.php b/Controller/ArticleController.php index 54680a74a..d562e865c 100644 --- a/Controller/ArticleController.php +++ b/Controller/ArticleController.php @@ -343,7 +343,7 @@ public function postTriggerAction($uuid, Request $request) $data = $this->getMapper()->copyLanguage($uuid, $userId, null, $locale, explode(',', $destLocales)); break; default: - throw new RestException('Unrecognized action: '.$action); + throw new RestException('Unrecognized action: ' . $action); } // prepare view diff --git a/Tests/app/AppKernel.php b/Tests/app/AppKernel.php index 3be28399f..5a7d8a8e6 100644 --- a/Tests/app/AppKernel.php +++ b/Tests/app/AppKernel.php @@ -35,14 +35,14 @@ public function registerContainerConfiguration(LoaderInterface $loader) parent::registerContainerConfiguration($loader); if (getenv('SYMFONY__PHPCR__TRANSPORT') === 'jackrabbit') { - $loader->load(__DIR__.'/config/versioning.yml'); + $loader->load(__DIR__ . '/config/versioning.yml'); } // If version is lower then 5.6 it is an testcase for elasticsearch 2.*, so different ONGR config is needed if (phpversion() < 5.6) { - $loader->load(__DIR__.'/config/config_es2.yml'); + $loader->load(__DIR__ . '/config/config_es2.yml'); } else { - $loader->load(__DIR__.'/config/config.yml'); + $loader->load(__DIR__ . '/config/config.yml'); } } } From c2c60d5692113e6565a668c63a3599cdcb3e5973 Mon Sep 17 00:00:00 2001 From: Frank Klein Koerkamp Date: Thu, 20 Apr 2017 13:13:57 +0200 Subject: [PATCH 07/29] Updated 5.5 ES version --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 338cae031..aee72fc4e 100644 --- a/composer.json +++ b/composer.json @@ -6,7 +6,7 @@ "require": { "php": "^5.5 || ^7.0", "sulu/sulu": "^1.5.3 || dev-develop", - "ongr/elasticsearch-bundle": "~1.0 || ~5.0" + "ongr/elasticsearch-bundle": "~1.2 || ~5.0" }, "require-dev": { "zendframework/zend-stdlib": "2.3.1 as 2.0.0rc5", From f163ee8b27c5fc71f126f03331227849fe1bdc3f Mon Sep 17 00:00:00 2001 From: Frank Klein Koerkamp Date: Thu, 20 Apr 2017 13:22:32 +0200 Subject: [PATCH 08/29] Updated ONGR version to minimal 1.2.9 --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index aee72fc4e..cd48ede8a 100644 --- a/composer.json +++ b/composer.json @@ -6,7 +6,7 @@ "require": { "php": "^5.5 || ^7.0", "sulu/sulu": "^1.5.3 || dev-develop", - "ongr/elasticsearch-bundle": "~1.2 || ~5.0" + "ongr/elasticsearch-bundle": "^1.2.9 || ~5.0" }, "require-dev": { "zendframework/zend-stdlib": "2.3.1 as 2.0.0rc5", From c135764fb755fe9702ee3ad187160e71cce2073e Mon Sep 17 00:00:00 2001 From: Frank Klein Koerkamp Date: Thu, 20 Apr 2017 16:00:53 +0200 Subject: [PATCH 09/29] Now making use of environment variable + updated travis --- .travis.yml | 12 +++++++++--- Tests/app/AppKernel.php | 3 +-- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index aaa099461..89f971809 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,13 +2,12 @@ sudo: false language: php -services: - - elasticsearch - env: global: - JACKRABBIT_VERSION=2.12.0 - SYMFONY__PHPCR__TRANSPORT=doctrinedbal + - ES_VERSION=5.3.0 + - ES_DOWNLOAD_URL=https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-${ES_VERSION}.tar.gz cache: directories: @@ -21,6 +20,8 @@ matrix: env: - SULU_VERSION="~1.5.1" - COMPOSER_FLAGS="--prefer-lowest --prefer-dist --no-interaction" + - ES_VERSION=2.4.4 + - ES_DOWNLOAD_URL=https://download.elastic.co/elasticsearch/release/org/elasticsearch/distribution/tar/elasticsearch/${ES_VERSION}/elasticsearch-${ES_VERSION}.tar.gz - php: 7.0 env: - COMPOSER_FLAGS="--prefer-dist --no-interaction" @@ -45,6 +46,10 @@ before_install: - if [[ -z $CODE_COVERAGE ]]; then phpenv config-rm xdebug.ini ; fi - phpenv config-add Tests/travis.php.ini - composer self-update + - wget ${ES_DOWNLOAD_URL} + - tar -xzf elasticsearch-${ES_VERSION}.tar.gz + - ./elasticsearch-${ES_VERSION}/bin/elasticsearch > elasticsearch.log 2>&1 & + - wget -q --waitretry=1 --retry-connrefused -T 10 -O - http://127.0.0.1:9200 install: - travis_retry composer require sulu/sulu:$SULU_VERSION $COMPOSER_FLAGS @@ -59,5 +64,6 @@ script: - ./vendor/bin/phpunit $CODE_COVERAGE after_script: + - cat elasticsearch.log - if [[ -n $CODE_COVERAGE ]]; then wget https://scrutinizer-ci.com/ocular.phar ; fi - if [[ -n $CODE_COVERAGE ]]; then php ocular.phar code-coverage:upload --format=php-clover coverage.clover ; fi diff --git a/Tests/app/AppKernel.php b/Tests/app/AppKernel.php index 5a7d8a8e6..547ad908b 100644 --- a/Tests/app/AppKernel.php +++ b/Tests/app/AppKernel.php @@ -38,8 +38,7 @@ public function registerContainerConfiguration(LoaderInterface $loader) $loader->load(__DIR__ . '/config/versioning.yml'); } - // If version is lower then 5.6 it is an testcase for elasticsearch 2.*, so different ONGR config is needed - if (phpversion() < 5.6) { + if (getenv('ES_VERSION') == '2.4.4') { $loader->load(__DIR__ . '/config/config_es2.yml'); } else { $loader->load(__DIR__ . '/config/config.yml'); From 080a68724a727340c52afeebe4e4f781275ed51b Mon Sep 17 00:00:00 2001 From: Frank Klein Koerkamp Date: Thu, 20 Apr 2017 16:22:01 +0200 Subject: [PATCH 10/29] Updated travis config for correct handling ES 5.* --- .travis.yml | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index 89f971809..5a6885878 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,13 +7,17 @@ env: - JACKRABBIT_VERSION=2.12.0 - SYMFONY__PHPCR__TRANSPORT=doctrinedbal - ES_VERSION=5.3.0 - - ES_DOWNLOAD_URL=https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-${ES_VERSION}.tar.gz cache: directories: - "downloads" - "$HOME/.composer/cache" +addons: + apt: + packages: + - oracle-java8-set-default + matrix: include: - php: 5.5 @@ -46,10 +50,17 @@ before_install: - if [[ -z $CODE_COVERAGE ]]; then phpenv config-rm xdebug.ini ; fi - phpenv config-add Tests/travis.php.ini - composer self-update - - wget ${ES_DOWNLOAD_URL} - - tar -xzf elasticsearch-${ES_VERSION}.tar.gz - - ./elasticsearch-${ES_VERSION}/bin/elasticsearch > elasticsearch.log 2>&1 & - - wget -q --waitretry=1 --retry-connrefused -T 10 -O - http://127.0.0.1:9200 + - | + if [[ $ES_VERSION = 2.4.4 ]]; then + wget https://download.elastic.co/elasticsearch/release/org/elasticsearch/distribution/tar/elasticsearch/${ES_VERSION}/elasticsearch-${ES_VERSION}.tar.gz + tar -xzf elasticsearch-${ES_VERSION}.tar.gz + ./elasticsearch-${ES_VERSION}/bin/elasticsearch > elasticsearch.log 2>&1 & + wget -q --waitretry=1 --retry-connrefused -T 10 -O - http://127.0.0.1:9200 + else + curl -O https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-${ES_VERSION}.deb + sudo dpkg -i --force-confnew elasticsearch-${ES_VERSION}.deb + sudo service elasticsearch start + fi install: - travis_retry composer require sulu/sulu:$SULU_VERSION $COMPOSER_FLAGS From 6f987b45fe2fec0723104c28bdfb66b20bd65fdf Mon Sep 17 00:00:00 2001 From: Frank Klein Koerkamp Date: Thu, 20 Apr 2017 16:41:32 +0200 Subject: [PATCH 11/29] Now with semicolon --- .travis.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.travis.yml b/.travis.yml index 5a6885878..ff1a1d87f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -52,14 +52,14 @@ before_install: - composer self-update - | if [[ $ES_VERSION = 2.4.4 ]]; then - wget https://download.elastic.co/elasticsearch/release/org/elasticsearch/distribution/tar/elasticsearch/${ES_VERSION}/elasticsearch-${ES_VERSION}.tar.gz - tar -xzf elasticsearch-${ES_VERSION}.tar.gz - ./elasticsearch-${ES_VERSION}/bin/elasticsearch > elasticsearch.log 2>&1 & - wget -q --waitretry=1 --retry-connrefused -T 10 -O - http://127.0.0.1:9200 + wget https://download.elastic.co/elasticsearch/release/org/elasticsearch/distribution/tar/elasticsearch/${ES_VERSION}/elasticsearch-${ES_VERSION}.tar.gz; + tar -xzf elasticsearch-${ES_VERSION}.tar.gz; + ./elasticsearch-${ES_VERSION}/bin/elasticsearch > elasticsearch.log 2>&1 &; + wget -q --waitretry=1 --retry-connrefused -T 10 -O - http://127.0.0.1:9200; else - curl -O https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-${ES_VERSION}.deb - sudo dpkg -i --force-confnew elasticsearch-${ES_VERSION}.deb - sudo service elasticsearch start + curl -O https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-${ES_VERSION}.deb; + sudo dpkg -i --force-confnew elasticsearch-${ES_VERSION}.deb; + sudo service elasticsearch start; fi install: From 42a893a7c601060aa9e327e83fee0697d9ff9aed Mon Sep 17 00:00:00 2001 From: Frank Klein Koerkamp Date: Thu, 20 Apr 2017 16:55:27 +0200 Subject: [PATCH 12/29] ES installation for Travis to seperate file --- .travis.yml | 12 +----------- Tests/scripts/install-travis-es.sh | 13 +++++++++++++ 2 files changed, 14 insertions(+), 11 deletions(-) create mode 100644 Tests/scripts/install-travis-es.sh diff --git a/.travis.yml b/.travis.yml index ff1a1d87f..59a90e4d8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -50,17 +50,7 @@ before_install: - if [[ -z $CODE_COVERAGE ]]; then phpenv config-rm xdebug.ini ; fi - phpenv config-add Tests/travis.php.ini - composer self-update - - | - if [[ $ES_VERSION = 2.4.4 ]]; then - wget https://download.elastic.co/elasticsearch/release/org/elasticsearch/distribution/tar/elasticsearch/${ES_VERSION}/elasticsearch-${ES_VERSION}.tar.gz; - tar -xzf elasticsearch-${ES_VERSION}.tar.gz; - ./elasticsearch-${ES_VERSION}/bin/elasticsearch > elasticsearch.log 2>&1 &; - wget -q --waitretry=1 --retry-connrefused -T 10 -O - http://127.0.0.1:9200; - else - curl -O https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-${ES_VERSION}.deb; - sudo dpkg -i --force-confnew elasticsearch-${ES_VERSION}.deb; - sudo service elasticsearch start; - fi + - ./Tests/scripts/install-travis-es.sh install: - travis_retry composer require sulu/sulu:$SULU_VERSION $COMPOSER_FLAGS diff --git a/Tests/scripts/install-travis-es.sh b/Tests/scripts/install-travis-es.sh new file mode 100644 index 000000000..6dcad847c --- /dev/null +++ b/Tests/scripts/install-travis-es.sh @@ -0,0 +1,13 @@ +#!/bin/bash +set -ev + +if [[ "${ES_VERSION}" = "2.4.4" ]]; then + wget https://download.elastic.co/elasticsearch/release/org/elasticsearch/distribution/tar/elasticsearch/${ES_VERSION}/elasticsearch-${ES_VERSION}.tar.gz + tar -xzf elasticsearch-${ES_VERSION}.tar.gz + ./elasticsearch-${ES_VERSION}/bin/elasticsearch > elasticsearch.log 2>&1 & + wget -q --waitretry=1 --retry-connrefused -T 10 -O - http://127.0.0.1:9200 +else + curl -O https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-${ES_VERSION}.deb + sudo dpkg -i --force-confnew elasticsearch-${ES_VERSION}.deb + sudo service elasticsearch start +fi \ No newline at end of file From c750ff61dee402ebb0f228ebff3fd1706348cb9b Mon Sep 17 00:00:00 2001 From: Frank Klein Koerkamp Date: Thu, 20 Apr 2017 18:29:05 +0200 Subject: [PATCH 13/29] Added echo for test --- Tests/scripts/install-travis-es.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Tests/scripts/install-travis-es.sh b/Tests/scripts/install-travis-es.sh index 6dcad847c..453302463 100644 --- a/Tests/scripts/install-travis-es.sh +++ b/Tests/scripts/install-travis-es.sh @@ -1,6 +1,8 @@ #!/bin/bash set -ev +echo $ES_VERSION; + if [[ "${ES_VERSION}" = "2.4.4" ]]; then wget https://download.elastic.co/elasticsearch/release/org/elasticsearch/distribution/tar/elasticsearch/${ES_VERSION}/elasticsearch-${ES_VERSION}.tar.gz tar -xzf elasticsearch-${ES_VERSION}.tar.gz From 1145233c69d0f37e99bee763a86605b704179803 Mon Sep 17 00:00:00 2001 From: Frank Klein Koerkamp Date: Thu, 20 Apr 2017 18:32:34 +0200 Subject: [PATCH 14/29] Updated permissions --- Tests/scripts/install-travis-es.sh | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 Tests/scripts/install-travis-es.sh diff --git a/Tests/scripts/install-travis-es.sh b/Tests/scripts/install-travis-es.sh old mode 100644 new mode 100755 From 3677810e84bd4fc2c9965ccface7ee35706455fd Mon Sep 17 00:00:00 2001 From: Frank Klein Koerkamp Date: Thu, 20 Apr 2017 18:36:28 +0200 Subject: [PATCH 15/29] Changed permission --- Tests/scripts/install-travis-es.sh | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 Tests/scripts/install-travis-es.sh diff --git a/Tests/scripts/install-travis-es.sh b/Tests/scripts/install-travis-es.sh old mode 100755 new mode 100644 From c90048c54b29fd58f7e69bb4c19096e64d1c275c Mon Sep 17 00:00:00 2001 From: Frank Klein Koerkamp Date: Thu, 20 Apr 2017 18:37:31 +0200 Subject: [PATCH 16/29] Updated permissions --- Tests/scripts/install-travis-es.sh | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 Tests/scripts/install-travis-es.sh diff --git a/Tests/scripts/install-travis-es.sh b/Tests/scripts/install-travis-es.sh old mode 100644 new mode 100755 From ba5fcf21d39a7ca4bff2fe7327396550676f8e3a Mon Sep 17 00:00:00 2001 From: Frank Klein Koerkamp Date: Fri, 21 Apr 2017 08:05:28 +0200 Subject: [PATCH 17/29] Added extra fix for permissions --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 59a90e4d8..f2f575cdc 100644 --- a/.travis.yml +++ b/.travis.yml @@ -38,6 +38,7 @@ matrix: - SYMFONY__PHPCR__TRANSPORT=jackrabbit before_install: + - chmod +x ./Tests/scripts/install-travis-es.sh - | if [[ $SYMFONY__PHPCR__TRANSPORT = jackrabbit ]]; then if [ ! -f downloads/jackrabbit-standalone-$JACKRABBIT_VERSION.jar ]; then From 5aeef77294bdbffdffb522aa82075fa9e2b33734 Mon Sep 17 00:00:00 2001 From: Frank Klein Koerkamp Date: Fri, 21 Apr 2017 08:24:26 +0200 Subject: [PATCH 18/29] Simplified logic for es script --- Tests/scripts/install-travis-es.sh | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Tests/scripts/install-travis-es.sh b/Tests/scripts/install-travis-es.sh index 453302463..fd96766f7 100755 --- a/Tests/scripts/install-travis-es.sh +++ b/Tests/scripts/install-travis-es.sh @@ -5,11 +5,11 @@ echo $ES_VERSION; if [[ "${ES_VERSION}" = "2.4.4" ]]; then wget https://download.elastic.co/elasticsearch/release/org/elasticsearch/distribution/tar/elasticsearch/${ES_VERSION}/elasticsearch-${ES_VERSION}.tar.gz - tar -xzf elasticsearch-${ES_VERSION}.tar.gz - ./elasticsearch-${ES_VERSION}/bin/elasticsearch > elasticsearch.log 2>&1 & - wget -q --waitretry=1 --retry-connrefused -T 10 -O - http://127.0.0.1:9200 + else - curl -O https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-${ES_VERSION}.deb - sudo dpkg -i --force-confnew elasticsearch-${ES_VERSION}.deb - sudo service elasticsearch start -fi \ No newline at end of file + wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-${ES_VERSION}.tar.gz +fi + +tar -xzf elasticsearch-${ES_VERSION}.tar.gz +./elasticsearch-${ES_VERSION}/bin/elasticsearch > elasticsearch.log 2>&1 & +wget -q --waitretry=1 --retry-connrefused -T 10 -O - http://127.0.0.1:9200 \ No newline at end of file From 356b8b0e19c22ad0d9e2c44c449a5d9380f11f2f Mon Sep 17 00:00:00 2001 From: Frank Klein Koerkamp Date: Fri, 21 Apr 2017 15:13:57 +0200 Subject: [PATCH 19/29] update sulu version for travis --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index f2f575cdc..4092886af 100644 --- a/.travis.yml +++ b/.travis.yml @@ -22,7 +22,7 @@ matrix: include: - php: 5.5 env: - - SULU_VERSION="~1.5.1" + - SULU_VERSION="~1.5.3" - COMPOSER_FLAGS="--prefer-lowest --prefer-dist --no-interaction" - ES_VERSION=2.4.4 - ES_DOWNLOAD_URL=https://download.elastic.co/elasticsearch/release/org/elasticsearch/distribution/tar/elasticsearch/${ES_VERSION}/elasticsearch-${ES_VERSION}.tar.gz @@ -34,7 +34,7 @@ matrix: - php: 7.0 env: - COMPOSER_FLAGS="--prefer-dist --no-interaction" - - SULU_VERSION="~1.5.1" + - SULU_VERSION="~1.5.3" - SYMFONY__PHPCR__TRANSPORT=jackrabbit before_install: From b0050a92cc4e79d0c9abf036ca6b7bf9e6746793 Mon Sep 17 00:00:00 2001 From: Frank Klein Koerkamp Date: Fri, 21 Apr 2017 15:52:04 +0200 Subject: [PATCH 20/29] Now back to only travis config file + ONGR DSL specific minimal version --- .travis.yml | 11 +++++++---- Tests/scripts/install-travis-es.sh | 15 --------------- 2 files changed, 7 insertions(+), 19 deletions(-) delete mode 100755 Tests/scripts/install-travis-es.sh diff --git a/.travis.yml b/.travis.yml index 4092886af..98206c686 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,7 +6,8 @@ env: global: - JACKRABBIT_VERSION=2.12.0 - SYMFONY__PHPCR__TRANSPORT=doctrinedbal - - ES_VERSION=5.3.0 + - ES_VERSION="5.3.0" + - ES_DOWNLOAD_URL=https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-${ES_VERSION}.tar.gz cache: directories: @@ -24,8 +25,8 @@ matrix: env: - SULU_VERSION="~1.5.3" - COMPOSER_FLAGS="--prefer-lowest --prefer-dist --no-interaction" - - ES_VERSION=2.4.4 - - ES_DOWNLOAD_URL=https://download.elastic.co/elasticsearch/release/org/elasticsearch/distribution/tar/elasticsearch/${ES_VERSION}/elasticsearch-${ES_VERSION}.tar.gz + - ES_VERSION="2.4.4" + - ES_DOWNLOAD_URL=https://download.elastic.co/elasticsearch/elasticsearch/elasticsearch-${ES_VERSION}.tar.gz - php: 7.0 env: - COMPOSER_FLAGS="--prefer-dist --no-interaction" @@ -51,7 +52,9 @@ before_install: - if [[ -z $CODE_COVERAGE ]]; then phpenv config-rm xdebug.ini ; fi - phpenv config-add Tests/travis.php.ini - composer self-update - - ./Tests/scripts/install-travis-es.sh + - wget ${ES_DOWNLOAD_URL} + - tar -xzf elasticsearch-${ES_VERSION}.tar.gz + - ./elasticsearch-${ES_VERSION}/bin/elasticsearch > /dev/null 2>&1 & install: - travis_retry composer require sulu/sulu:$SULU_VERSION $COMPOSER_FLAGS diff --git a/Tests/scripts/install-travis-es.sh b/Tests/scripts/install-travis-es.sh deleted file mode 100755 index fd96766f7..000000000 --- a/Tests/scripts/install-travis-es.sh +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/bash -set -ev - -echo $ES_VERSION; - -if [[ "${ES_VERSION}" = "2.4.4" ]]; then - wget https://download.elastic.co/elasticsearch/release/org/elasticsearch/distribution/tar/elasticsearch/${ES_VERSION}/elasticsearch-${ES_VERSION}.tar.gz - -else - wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-${ES_VERSION}.tar.gz -fi - -tar -xzf elasticsearch-${ES_VERSION}.tar.gz -./elasticsearch-${ES_VERSION}/bin/elasticsearch > elasticsearch.log 2>&1 & -wget -q --waitretry=1 --retry-connrefused -T 10 -O - http://127.0.0.1:9200 \ No newline at end of file From 5935d7eadc29ca0b6feac4abd559c647b2247d52 Mon Sep 17 00:00:00 2001 From: Frank Klein Koerkamp Date: Fri, 21 Apr 2017 15:52:30 +0200 Subject: [PATCH 21/29] ONGR ES minimal version --- composer.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index cd48ede8a..100e1f00b 100644 --- a/composer.json +++ b/composer.json @@ -6,7 +6,8 @@ "require": { "php": "^5.5 || ^7.0", "sulu/sulu": "^1.5.3 || dev-develop", - "ongr/elasticsearch-bundle": "^1.2.9 || ~5.0" + "ongr/elasticsearch-bundle": "^1.2.9 || ~5.0", + "ongr/elasticsearch-dsl": "^2.2.2 || ~5.0" }, "require-dev": { "zendframework/zend-stdlib": "2.3.1 as 2.0.0rc5", From 8735f9a023796a06556c361b57105735d2f2b7ca Mon Sep 17 00:00:00 2001 From: Frank Klein Koerkamp Date: Fri, 21 Apr 2017 15:55:51 +0200 Subject: [PATCH 22/29] Removed unused line --- .travis.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 98206c686..ce56a9227 100644 --- a/.travis.yml +++ b/.travis.yml @@ -39,7 +39,6 @@ matrix: - SYMFONY__PHPCR__TRANSPORT=jackrabbit before_install: - - chmod +x ./Tests/scripts/install-travis-es.sh - | if [[ $SYMFONY__PHPCR__TRANSPORT = jackrabbit ]]; then if [ ! -f downloads/jackrabbit-standalone-$JACKRABBIT_VERSION.jar ]; then From 5e99a9893f487a1ae66da5d87c054580590d1ded Mon Sep 17 00:00:00 2001 From: Frank Klein Koerkamp Date: Fri, 21 Apr 2017 16:04:23 +0200 Subject: [PATCH 23/29] Changed Installation of ES for travis now same as https://github.com/ongr-io/ElasticsearchBundle/blob/master/.travis.yml --- .travis.yml | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/.travis.yml b/.travis.yml index ce56a9227..14360e794 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,21 +4,17 @@ language: php env: global: + - JAVA_HOME="/usr/lib/jvm/java-8-oracle/jre" - JACKRABBIT_VERSION=2.12.0 - SYMFONY__PHPCR__TRANSPORT=doctrinedbal - ES_VERSION="5.3.0" - - ES_DOWNLOAD_URL=https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-${ES_VERSION}.tar.gz + - ES_DOWNLOAD_URL="https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-${ES_VERSION}.zip" cache: directories: - "downloads" - "$HOME/.composer/cache" -addons: - apt: - packages: - - oracle-java8-set-default - matrix: include: - php: 5.5 @@ -26,7 +22,7 @@ matrix: - SULU_VERSION="~1.5.3" - COMPOSER_FLAGS="--prefer-lowest --prefer-dist --no-interaction" - ES_VERSION="2.4.4" - - ES_DOWNLOAD_URL=https://download.elastic.co/elasticsearch/elasticsearch/elasticsearch-${ES_VERSION}.tar.gz + - ES_DOWNLOAD_URL="https://download.elastic.co/elasticsearch/elasticsearch/elasticsearch-${ES_VERSION}.zip" - php: 7.0 env: - COMPOSER_FLAGS="--prefer-dist --no-interaction" @@ -39,6 +35,8 @@ matrix: - SYMFONY__PHPCR__TRANSPORT=jackrabbit before_install: + # Container based PHP image ues PHP 5.5, once it will be upgraded sudo will be not necessary + - sudo apt-get install -y oracle-java8-set-default - | if [[ $SYMFONY__PHPCR__TRANSPORT = jackrabbit ]]; then if [ ! -f downloads/jackrabbit-standalone-$JACKRABBIT_VERSION.jar ]; then @@ -51,9 +49,9 @@ before_install: - if [[ -z $CODE_COVERAGE ]]; then phpenv config-rm xdebug.ini ; fi - phpenv config-add Tests/travis.php.ini - composer self-update - - wget ${ES_DOWNLOAD_URL} - - tar -xzf elasticsearch-${ES_VERSION}.tar.gz - - ./elasticsearch-${ES_VERSION}/bin/elasticsearch > /dev/null 2>&1 & + - curl -L -o elasticsearch.zip ${ES_DOWNLOAD_URL} + - unzip elasticsearch.zip + - ./elasticsearch-*/bin/elasticsearch -d install: - travis_retry composer require sulu/sulu:$SULU_VERSION $COMPOSER_FLAGS From 1ee0799300d92a793e10bebd720a5c6c7a0baebf Mon Sep 17 00:00:00 2001 From: Frank Klein Koerkamp Date: Fri, 21 Apr 2017 16:07:35 +0200 Subject: [PATCH 24/29] Fix sudo error --- .travis.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 14360e794..45388a814 100644 --- a/.travis.yml +++ b/.travis.yml @@ -35,8 +35,6 @@ matrix: - SYMFONY__PHPCR__TRANSPORT=jackrabbit before_install: - # Container based PHP image ues PHP 5.5, once it will be upgraded sudo will be not necessary - - sudo apt-get install -y oracle-java8-set-default - | if [[ $SYMFONY__PHPCR__TRANSPORT = jackrabbit ]]; then if [ ! -f downloads/jackrabbit-standalone-$JACKRABBIT_VERSION.jar ]; then From 375c78b0c88e2b95329b8f70239b9bd2d268e54d Mon Sep 17 00:00:00 2001 From: Frank Klein Koerkamp Date: Fri, 21 Apr 2017 16:10:58 +0200 Subject: [PATCH 25/29] Fix for travis --- .travis.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.travis.yml b/.travis.yml index 45388a814..92c85e517 100644 --- a/.travis.yml +++ b/.travis.yml @@ -33,8 +33,14 @@ matrix: - COMPOSER_FLAGS="--prefer-dist --no-interaction" - SULU_VERSION="~1.5.3" - SYMFONY__PHPCR__TRANSPORT=jackrabbit +addons: + apt: + packages: + - oracle-java8-installer before_install: + # Container based PHP image ues PHP 5.6.5, once it will be upgraded sudo will be not necessary + - sudo apt-get install -y oracle-java8-set-default - | if [[ $SYMFONY__PHPCR__TRANSPORT = jackrabbit ]]; then if [ ! -f downloads/jackrabbit-standalone-$JACKRABBIT_VERSION.jar ]; then From 8ff40ed57826cdf8ed3f1caa846639a5d978de79 Mon Sep 17 00:00:00 2001 From: Frank Klein Koerkamp Date: Fri, 21 Apr 2017 16:15:37 +0200 Subject: [PATCH 26/29] Allowing sudo --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 92c85e517..80383f189 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,4 +1,4 @@ -sudo: false +sudo: true language: php From 156285a8aba2e32a332bc35f237546e0f611408a Mon Sep 17 00:00:00 2001 From: Frank Klein Koerkamp Date: Fri, 21 Apr 2017 16:57:50 +0200 Subject: [PATCH 27/29] Sort test fix, extra option needed for ES5 --- Document/ArticleViewDocument.php | 1 + 1 file changed, 1 insertion(+) diff --git a/Document/ArticleViewDocument.php b/Document/ArticleViewDocument.php index 4cfed18d0..36c7684b9 100644 --- a/Document/ArticleViewDocument.php +++ b/Document/ArticleViewDocument.php @@ -50,6 +50,7 @@ class ArticleViewDocument implements ArticleViewDocumentInterface * @Property( * type="string", * options={ + * "fielddata":true, * "fields":{ * "raw":{"type":"string", "index":"not_analyzed"}, * "value":{"type":"string"} From b80175aa1af5b7c483fa1b94577329f9cb425c10 Mon Sep 17 00:00:00 2001 From: Frank Klein Koerkamp Date: Fri, 21 Apr 2017 17:20:22 +0200 Subject: [PATCH 28/29] Fixed test + updated docs --- Document/ArticleViewDocument.php | 1 - README.md | 2 +- Resources/doc/installation.md | 55 ++--------------- Resources/doc/installation_es2.md | 61 +++++++++++++++++++ Resources/doc/installation_es5.md | 58 ++++++++++++++++++ .../Controller/ArticleControllerTest.php | 2 +- UPGRADE.md | 6 ++ 7 files changed, 133 insertions(+), 52 deletions(-) create mode 100644 Resources/doc/installation_es2.md create mode 100644 Resources/doc/installation_es5.md diff --git a/Document/ArticleViewDocument.php b/Document/ArticleViewDocument.php index 36c7684b9..4cfed18d0 100644 --- a/Document/ArticleViewDocument.php +++ b/Document/ArticleViewDocument.php @@ -50,7 +50,6 @@ class ArticleViewDocument implements ArticleViewDocumentInterface * @Property( * type="string", * options={ - * "fielddata":true, * "fields":{ * "raw":{"type":"string", "index":"not_analyzed"}, * "value":{"type":"string"} diff --git a/README.md b/README.md index 274c0bb7e..83981fca4 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,7 @@ and code are not stable yet (pre 1.0). * Composer * PHP `^5.5 || ^7.0` * Sulu `^1.5` -* Elasticsearch `^2.2` +* Elasticsearch `^2.2 || ^5.0` For detailed requirements see [composer.json](https://github.com/sulu/SuluArticleBundle/blob/master/composer.json). diff --git a/Resources/doc/installation.md b/Resources/doc/installation.md index 59ae70861..d59457d83 100644 --- a/Resources/doc/installation.md +++ b/Resources/doc/installation.md @@ -2,58 +2,13 @@ ## Install ElasticSearch -The sulu article bundle requires a running elasticsearch `^2.2`. +The sulu article bundle requires a running elasticsearch `^2.2` or `^5.0`. -## Install bundle over composer: +There is an different installation and configuration depending on which version of ElasticSearch you are using. -```bash -composer require sulu/article-bundle -``` +If you use version `^2.2` read: [Installation for ElasticSearch 2.2](installation_es2.md) +else read: [Installation for ElasticSearch 5.0](installation_es5.md) -**Add bundle to AbstractKernel:** - -```php -/* app/AbstractKernel.php */ - -new Sulu\Bundle\ArticleBundle\SuluArticleBundle(), -new ONGR\ElasticsearchBundle\ONGRElasticsearchBundle(), -``` - -## Configure the bundles: - -```yml -# app/config/config.yml - -sulu_route: - mappings: - Sulu\Bundle\ArticleBundle\Document\ArticleDocument: - generator: schema - options: - route_schema: /articles/{object.getTitle()} - -sulu_core: - content: - structure: - default_type: - article: "article_default" - paths: - article: - path: "%kernel.root_dir%/Resources/templates/articles" - type: "article" - -ongr_elasticsearch: - managers: - default: - index: - index_name: su_articles - mappings: - - SuluArticleBundle - live: - index: - index_name: su_articles_live - mappings: - - SuluArticleBundle -``` ## Configure the routing @@ -134,3 +89,5 @@ sulu_article: # Display tab 'all' in list view display_tab_all: true ``` + + diff --git a/Resources/doc/installation_es2.md b/Resources/doc/installation_es2.md new file mode 100644 index 000000000..b218c357a --- /dev/null +++ b/Resources/doc/installation_es2.md @@ -0,0 +1,61 @@ +# Installation + + +## Install ElasticSearch + +The sulu article bundle requires a running elasticsearch `^2.2`. + +## Install bundle over composer: + +```bash +composer require ongr/elasticsearch-bundle:1.2.9 +composer require sulu/article-bundle +``` + +**Add bundle to AbstractKernel:** + +```php +/* app/AbstractKernel.php */ + +new Sulu\Bundle\ArticleBundle\SuluArticleBundle(), +new ONGR\ElasticsearchBundle\ONGRElasticsearchBundle(), +``` + +## Configure the bundles: + +```yml +# app/config/config.yml + +sulu_route: + mappings: + Sulu\Bundle\ArticleBundle\Document\ArticleDocument: + generator: schema + options: + route_schema: /articles/{object.getTitle()} + +sulu_core: + content: + structure: + default_type: + article: "article_default" + paths: + article: + path: "%kernel.root_dir%/Resources/templates/articles" + type: "article" + +ongr_elasticsearch: + connections: + default: + index_name: su_articles_test + live: + index_name: su_articles_test_live + managers: + default: + connection: default + mappings: + - SuluArticleBundle + live: + connection: live + mappings: + - SuluArticleBundle +``` diff --git a/Resources/doc/installation_es5.md b/Resources/doc/installation_es5.md new file mode 100644 index 000000000..547484d3a --- /dev/null +++ b/Resources/doc/installation_es5.md @@ -0,0 +1,58 @@ +# Installation + +If you w + +## Install ElasticSearch + +The sulu article bundle requires a running elasticsearch `^2.2` or `^5.0`. + +## Install bundle over composer: + +```bash +composer require sulu/article-bundle +``` + +**Add bundle to AbstractKernel:** + +```php +/* app/AbstractKernel.php */ + +new Sulu\Bundle\ArticleBundle\SuluArticleBundle(), +new ONGR\ElasticsearchBundle\ONGRElasticsearchBundle(), +``` + +## Configure the bundles: + +```yml +# app/config/config.yml + +sulu_route: + mappings: + Sulu\Bundle\ArticleBundle\Document\ArticleDocument: + generator: schema + options: + route_schema: /articles/{object.getTitle()} + +sulu_core: + content: + structure: + default_type: + article: "article_default" + paths: + article: + path: "%kernel.root_dir%/Resources/templates/articles" + type: "article" + +ongr_elasticsearch: + managers: + default: + index: + index_name: su_articles + mappings: + - SuluArticleBundle + live: + index: + index_name: su_articles_live + mappings: + - SuluArticleBundle +``` diff --git a/Tests/Functional/Controller/ArticleControllerTest.php b/Tests/Functional/Controller/ArticleControllerTest.php index 68e4680f0..d74ba1506 100644 --- a/Tests/Functional/Controller/ArticleControllerTest.php +++ b/Tests/Functional/Controller/ArticleControllerTest.php @@ -421,7 +421,7 @@ public function testCGetSort() $this->flush(); $client = $this->createAuthenticatedClient(); - $client->request('GET', '/api/articles?locale=de&sortBy=title&sortOrder=desc&type=blog'); + $client->request('GET', '/api/articles?locale=de&sortBy=title.raw&sortOrder=desc&type=blog'); $this->assertHttpStatusCode(200, $client->getResponse()); diff --git a/UPGRADE.md b/UPGRADE.md index a1e835ae8..39dd7e948 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -13,3 +13,9 @@ with the cachelifetime resolver. Reindex elastic search indexes: * bin/adminconsole sulu:article:index-rebuild ###LOCALE### -live * bin/adminconsole sulu:article:index-rebuild ###LOCALE### + + +## 0.5.0 + +Now also support for ElasticSearch 5. To still be compatible with ^2.2, make sure you run: +* composer require ongr/elasticsearch-bundle:1.2.9 From e69ccd2f832a6425d53f55f6856434a0a4669216 Mon Sep 17 00:00:00 2001 From: Frank Klein Koerkamp Date: Mon, 24 Apr 2017 08:12:28 +0200 Subject: [PATCH 29/29] Fixed comments on PR --- .travis.yml | 1 - Resources/doc/installation_es5.md | 2 -- Tests/app/AppKernel.php | 4 +++- UPGRADE.md | 8 +++----- 4 files changed, 6 insertions(+), 9 deletions(-) diff --git a/.travis.yml b/.travis.yml index 80383f189..d98cd17c2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -70,6 +70,5 @@ script: - ./vendor/bin/phpunit $CODE_COVERAGE after_script: - - cat elasticsearch.log - if [[ -n $CODE_COVERAGE ]]; then wget https://scrutinizer-ci.com/ocular.phar ; fi - if [[ -n $CODE_COVERAGE ]]; then php ocular.phar code-coverage:upload --format=php-clover coverage.clover ; fi diff --git a/Resources/doc/installation_es5.md b/Resources/doc/installation_es5.md index 547484d3a..fcee714c3 100644 --- a/Resources/doc/installation_es5.md +++ b/Resources/doc/installation_es5.md @@ -1,7 +1,5 @@ # Installation -If you w - ## Install ElasticSearch The sulu article bundle requires a running elasticsearch `^2.2` or `^5.0`. diff --git a/Tests/app/AppKernel.php b/Tests/app/AppKernel.php index 547ad908b..f5e4e5d9b 100644 --- a/Tests/app/AppKernel.php +++ b/Tests/app/AppKernel.php @@ -38,7 +38,9 @@ public function registerContainerConfiguration(LoaderInterface $loader) $loader->load(__DIR__ . '/config/versioning.yml'); } - if (getenv('ES_VERSION') == '2.4.4') { + $esVersion = getenv('ES_VERSION'); + if (version_compare($esVersion, '2.2', '>=') && + version_compare($esVersion, '5.0', '<')) { $loader->load(__DIR__ . '/config/config_es2.yml'); } else { $loader->load(__DIR__ . '/config/config.yml'); diff --git a/UPGRADE.md b/UPGRADE.md index 39dd7e948..f0517fb79 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -8,14 +8,12 @@ The `_cacheLifetime` attribute available in the request parameter of a article controller will return the seconds and don't need longer be resolved manually with the cachelifetime resolver. +Now also support for ElasticSearch 5. To still be compatible with ^2.2, make sure you run: +* composer require ongr/elasticsearch-bundle:1.2.9 + ## 0.2.0 Reindex elastic search indexes: * bin/adminconsole sulu:article:index-rebuild ###LOCALE### -live * bin/adminconsole sulu:article:index-rebuild ###LOCALE### - -## 0.5.0 - -Now also support for ElasticSearch 5. To still be compatible with ^2.2, make sure you run: -* composer require ongr/elasticsearch-bundle:1.2.9