From e45e8b21cf7cab78fb9c937a786dba56b517f6a2 Mon Sep 17 00:00:00 2001 From: Alexander Schranz Date: Tue, 16 Jul 2024 11:34:09 +0200 Subject: [PATCH 1/9] Upgrade to Symfony 7 --- .github/workflows/test-application.yaml | 6 ++++-- DependencyInjection/Configuration.php | 2 +- composer.json | 22 +++++++++++----------- 3 files changed, 16 insertions(+), 14 deletions(-) diff --git a/.github/workflows/test-application.yaml b/.github/workflows/test-application.yaml index 6db92ac7..cd60bb90 100644 --- a/.github/workflows/test-application.yaml +++ b/.github/workflows/test-application.yaml @@ -136,8 +136,10 @@ jobs: tools: ${{ matrix.tools }} coverage: none - - name: Remove not required tooling - run: composer remove php-cs-fixer/shim "*phpstan*" --dev --no-interaction --no-update + - name: Remove Lint Tools + # These tools are not required to run tests, so we are removing them to improve dependency resolving and + # testing lowest versions. + run: composer remove "*php-cs-fixer*" "*phpstan*" "*rector*" --dev --no-update - name: Require elasticsearch dependency run: composer require --dev elasticsearch/elasticsearch:"${{ matrix.elasticsearch-package-constraint }}" --no-interaction --no-update diff --git a/DependencyInjection/Configuration.php b/DependencyInjection/Configuration.php index efd5a5b2..3704c1ab 100644 --- a/DependencyInjection/Configuration.php +++ b/DependencyInjection/Configuration.php @@ -21,7 +21,7 @@ */ class Configuration implements ConfigurationInterface { - public function getConfigTreeBuilder() + public function getConfigTreeBuilder(): TreeBuilder { $treeBuilder = new TreeBuilder('sulu_article'); $rootNode = $treeBuilder->getRootNode(); diff --git a/composer.json b/composer.json index a5348685..e0b0bb5e 100644 --- a/composer.json +++ b/composer.json @@ -26,18 +26,18 @@ "jms/serializer": "^3.3", "jms/serializer-bundle": "^3.3 || ^4.0", "sulu/sulu": "~2.4.13 || ^2.5.9@dev", - "symfony/config": "^4.3 || ^5.0 || ^6.0", - "symfony/dependency-injection": "^4.3 || ^5.0 || ^6.0", - "symfony/http-foundation": "^4.3 || ^5.0 || ^6.0", - "symfony/http-kernel": "^4.3 || ^5.0 || ^6.0", + "symfony/config": "^4.3 || ^5.0 || ^6.0 || ^7.0", + "symfony/dependency-injection": "^4.3 || ^5.0 || ^6.0 || ^7.0", + "symfony/http-foundation": "^4.3 || ^5.0 || ^6.0 || ^7.0", + "symfony/http-kernel": "^4.3 || ^5.0 || ^6.0 || ^7.0", "symfony-cmf/slugifier-api": "^1.0 || ^2.0", "twig/twig": "^1.41 || ^2.0 || ^3.0" }, "require-dev": { "doctrine/data-fixtures": "^1.1", "handcraftedinthealps/zendsearch": "^2.0", - "jackalope/jackalope-doctrine-dbal": "^1.3.4", - "jackalope/jackalope-jackrabbit": "^1.3", + "jackalope/jackalope-doctrine-dbal": "^1.3.4 || ^2.0", + "jackalope/jackalope-jackrabbit": "^1.3 || ^2.0", "jangregor/phpstan-prophecy": "^1.0", "massive/build-bundle": "^0.3 || ^0.4 || ^0.5", "php-cs-fixer/shim": "^3.0", @@ -51,12 +51,12 @@ "phpunit/phpunit": "^8.2", "sulu/automation-bundle": "^2.0 || ^2.1@dev", "sulu/headless-bundle": "^0.8 || ^0.9 || ^0.10@dev", - "symfony/browser-kit": "^4.3 || ^5.0 || ^6.0", - "symfony/dotenv": "^4.3 || ^5.0 || ^6.0", - "symfony/framework-bundle": "^4.3 || ^5.0 || ^6.0", + "symfony/browser-kit": "^4.3 || ^5.0 || ^6.0 || ^7.0", + "symfony/dotenv": "^4.3 || ^5.0 || ^6.0 || ^7.0", + "symfony/framework-bundle": "^4.3 || ^5.0 || ^6.0 || ^7.0", "symfony/monolog-bundle": "^3.1", - "symfony/security-bundle": "^4.3 || ^5.0 || ^6.0", - "symfony/stopwatch": "^4.3 || ^5.0 || ^6.0" + "symfony/security-bundle": "^4.3 || ^5.0 || ^6.0 || ^7.0", + "symfony/stopwatch": "^4.3 || ^5.0 || ^6.0 || ^7.0" }, "conflict": { "guzzlehttp/ringphp": "<1.1.1", From 3191637c5b46835bbf23ea11e3a279f305c43a66 Mon Sep 17 00:00:00 2001 From: Alexander Schranz Date: Tue, 16 Jul 2024 17:10:06 +0200 Subject: [PATCH 2/9] Fix jackalope 2 compatibility --- .../Sulu/Content/ArticleContentQueryBuilderTest.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Tests/Functional/Infrastructure/Sulu/Content/ArticleContentQueryBuilderTest.php b/Tests/Functional/Infrastructure/Sulu/Content/ArticleContentQueryBuilderTest.php index c8ffdce0..713aa07f 100644 --- a/Tests/Functional/Infrastructure/Sulu/Content/ArticleContentQueryBuilderTest.php +++ b/Tests/Functional/Infrastructure/Sulu/Content/ArticleContentQueryBuilderTest.php @@ -413,7 +413,9 @@ private function save( if (!$isShadow) { /* @var ArticleDocument $document */ try { - $document = $this->documentManager->find($uuid, $locale, ['load_ghost_content' => false]); + $document = $uuid + ? $this->documentManager->find($uuid, $locale, ['load_ghost_content' => false]) + : $this->documentManager->create('article'); } catch (DocumentNotFoundException $e) { $document = $this->documentManager->create('article'); } From 8e2bd9a782006a28b5e1692c271169c53768b439 Mon Sep 17 00:00:00 2001 From: Alexander Schranz Date: Tue, 16 Jul 2024 17:13:19 +0200 Subject: [PATCH 3/9] Allow installation of jms serializer bundel 5 --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index e0b0bb5e..2ea55856 100644 --- a/composer.json +++ b/composer.json @@ -24,7 +24,7 @@ "handcraftedinthealps/elasticsearch-bundle": "^5.2.6.4", "handcraftedinthealps/elasticsearch-dsl": "^5.0.7.1 || ^6.2.0.1 || ^7.2.0.1", "jms/serializer": "^3.3", - "jms/serializer-bundle": "^3.3 || ^4.0", + "jms/serializer-bundle": "^3.3 || ^4.0 || ^5.0", "sulu/sulu": "~2.4.13 || ^2.5.9@dev", "symfony/config": "^4.3 || ^5.0 || ^6.0 || ^7.0", "symfony/dependency-injection": "^4.3 || ^5.0 || ^6.0 || ^7.0", From d4a0eb06039b9e54a6672914081736e21782ec57 Mon Sep 17 00:00:00 2001 From: Alexander Schranz Date: Tue, 16 Jul 2024 18:47:10 +0200 Subject: [PATCH 4/9] Test Symfony 7 branch --- .github/workflows/test-application.yaml | 2 +- Command/ArticleExportCommand.php | 4 ++-- Command/ArticleImportCommand.php | 4 ++-- Command/ReindexCommand.php | 4 ++-- composer.json | 8 +++++++- 5 files changed, 14 insertions(+), 8 deletions(-) diff --git a/.github/workflows/test-application.yaml b/.github/workflows/test-application.yaml index cd60bb90..33a26a53 100644 --- a/.github/workflows/test-application.yaml +++ b/.github/workflows/test-application.yaml @@ -85,7 +85,7 @@ jobs: - php-version: '8.3' elasticsearch-version: '7.11.1' elasticsearch-package-constraint: '~7.11.0' - phpcr-transport: jackrabbit + phpcr-transport: doctrinedbal dependency-versions: 'highest' php-extensions: 'ctype, iconv, mysql, imagick' tools: 'composer:v2' diff --git a/Command/ArticleExportCommand.php b/Command/ArticleExportCommand.php index 10a30ed8..ba69b08c 100644 --- a/Command/ArticleExportCommand.php +++ b/Command/ArticleExportCommand.php @@ -35,7 +35,7 @@ public function __construct(ArticleExportInterface $articleExporter) $this->articleExporter = $articleExporter; } - protected function configure() + protected function configure(): void { $this->addArgument('target', InputArgument::REQUIRED, 'export.xliff') ->addArgument('locale', InputArgument::REQUIRED) @@ -43,7 +43,7 @@ protected function configure() ->setDescription('Export article translations from given language into xliff file for translating into a new language.'); } - protected function execute(InputInterface $input, OutputInterface $output) + protected function execute(InputInterface $input, OutputInterface $output): int { $target = $input->getArgument('target'); if (0 === !\strpos($target, '/')) { diff --git a/Command/ArticleImportCommand.php b/Command/ArticleImportCommand.php index 6275a675..7e52b41b 100644 --- a/Command/ArticleImportCommand.php +++ b/Command/ArticleImportCommand.php @@ -45,7 +45,7 @@ public function __construct(ArticleImportInterface $articleImporter, ?LoggerInte $this->logger = $logger ?: new NullLogger(); } - protected function configure() + protected function configure(): void { $this->addArgument('file', InputArgument::REQUIRED, 'export.xliff') ->addArgument('locale', InputArgument::REQUIRED) @@ -55,7 +55,7 @@ protected function configure() ->setDescription('Import article translations from xliff file into a specific language.'); } - protected function execute(InputInterface $input, OutputInterface $output) + protected function execute(InputInterface $input, OutputInterface $output): int { $filePath = $input->getArgument('file'); if (0 === !\strpos($filePath, '/')) { diff --git a/Command/ReindexCommand.php b/Command/ReindexCommand.php index 67598f61..57a94a91 100644 --- a/Command/ReindexCommand.php +++ b/Command/ReindexCommand.php @@ -77,7 +77,7 @@ public function __construct( $this->suluContext = $suluContext; } - public function configure() + public function configure(): void { $this->setDescription('Rebuild elastic-search index for articles'); $this->setHelp('This command will load all articles and index them to elastic-search indexes.'); @@ -85,7 +85,7 @@ public function configure() $this->addOption('clear', null, InputOption::VALUE_NONE, 'Clear all articles of index before reindex'); } - protected function execute(InputInterface $input, OutputInterface $output) + protected function execute(InputInterface $input, OutputInterface $output): int { $startTime = \microtime(true); diff --git a/composer.json b/composer.json index 2ea55856..6db56a34 100644 --- a/composer.json +++ b/composer.json @@ -17,11 +17,17 @@ "homepage": "https://github.com/sulu/SuluArticleBundle/contributors" } ], + "repositories": [ + { + "type": "vcs", + "url": "git@github.com:alexander-schranz/ElasticsearchBundle.git" + } + ], "require": { "php": "^7.3 || ^8.0", "ext-json": "*", "elasticsearch/elasticsearch": "^5.0 || ^6.0 || ^7.0", - "handcraftedinthealps/elasticsearch-bundle": "^5.2.6.4", + "handcraftedinthealps/elasticsearch-bundle": "dev-feature/symfony-7-upgrade as 5.999", "handcraftedinthealps/elasticsearch-dsl": "^5.0.7.1 || ^6.2.0.1 || ^7.2.0.1", "jms/serializer": "^3.3", "jms/serializer-bundle": "^3.3 || ^4.0 || ^5.0", From 955017e47d338a202d0ff579348d125fd60eb7a8 Mon Sep 17 00:00:00 2001 From: Alexander Schranz Date: Wed, 17 Jul 2024 09:13:02 +0200 Subject: [PATCH 5/9] Test support for PHP 8.4 --- .github/workflows/test-application.yaml | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test-application.yaml b/.github/workflows/test-application.yaml index 33a26a53..da423343 100644 --- a/.github/workflows/test-application.yaml +++ b/.github/workflows/test-application.yaml @@ -83,8 +83,21 @@ jobs: ELASTICSEARCH_HOST: '127.0.0.1:9200' - php-version: '8.3' - elasticsearch-version: '7.11.1' - elasticsearch-package-constraint: '~7.11.0' + elasticsearch-version: '7.17.2' + elasticsearch-package-constraint: '~7.17.0' + phpcr-transport: jackrabbit + dependency-versions: 'highest' + php-extensions: 'ctype, iconv, mysql, imagick' + tools: 'composer:v2' + phpstan: false + env: + SYMFONY_DEPRECATIONS_HELPER: weak + ELASTICSEARCH_HOST: '127.0.0.1:9200' + + - php-version: '8.4' + composer-options: '--ignore-platform-reqs' + elasticsearch-version: '7.17.2' + elasticsearch-package-constraint: '~7.17.0' phpcr-transport: doctrinedbal dependency-versions: 'highest' php-extensions: 'ctype, iconv, mysql, imagick' From df52edd25ce70f0992306b897f7c1e774b0fb719 Mon Sep 17 00:00:00 2001 From: Alexander Schranz Date: Wed, 17 Jul 2024 09:15:07 +0200 Subject: [PATCH 6/9] Apply suggestions from code review --- composer.json | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/composer.json b/composer.json index 6db56a34..b435df70 100644 --- a/composer.json +++ b/composer.json @@ -17,17 +17,11 @@ "homepage": "https://github.com/sulu/SuluArticleBundle/contributors" } ], - "repositories": [ - { - "type": "vcs", - "url": "git@github.com:alexander-schranz/ElasticsearchBundle.git" - } - ], "require": { "php": "^7.3 || ^8.0", "ext-json": "*", "elasticsearch/elasticsearch": "^5.0 || ^6.0 || ^7.0", - "handcraftedinthealps/elasticsearch-bundle": "dev-feature/symfony-7-upgrade as 5.999", + "handcraftedinthealps/elasticsearch-bundle": "^5.2.6.4 || ^5.2.6.4@dev", "handcraftedinthealps/elasticsearch-dsl": "^5.0.7.1 || ^6.2.0.1 || ^7.2.0.1", "jms/serializer": "^3.3", "jms/serializer-bundle": "^3.3 || ^4.0 || ^5.0", From 4906cfe48848a0342c4dfd65cd76fd42315c2a4c Mon Sep 17 00:00:00 2001 From: Alexander Schranz Date: Wed, 17 Jul 2024 09:28:02 +0200 Subject: [PATCH 7/9] Fix lint commands --- Command/ArticleExportCommand.php | 6 +++++- Command/ArticleImportCommand.php | 5 ++++- Command/ReindexCommand.php | 7 ++++++- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/Command/ArticleExportCommand.php b/Command/ArticleExportCommand.php index ba69b08c..65b37d7f 100644 --- a/Command/ArticleExportCommand.php +++ b/Command/ArticleExportCommand.php @@ -12,6 +12,7 @@ namespace Sulu\Bundle\ArticleBundle\Command; use Sulu\Bundle\ArticleBundle\Export\ArticleExportInterface; +use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; @@ -21,6 +22,9 @@ class ArticleExportCommand extends Command { + /** + * @var string + */ protected static $defaultName = 'sulu:article:export'; /** @@ -30,7 +34,7 @@ class ArticleExportCommand extends Command public function __construct(ArticleExportInterface $articleExporter) { - parent::__construct(); + parent::__construct(static::$defaultName); $this->articleExporter = $articleExporter; } diff --git a/Command/ArticleImportCommand.php b/Command/ArticleImportCommand.php index 7e52b41b..f0eb8a28 100644 --- a/Command/ArticleImportCommand.php +++ b/Command/ArticleImportCommand.php @@ -25,6 +25,9 @@ class ArticleImportCommand extends Command { + /** + * @var string + */ protected static $defaultName = 'sulu:article:import'; /** @@ -39,7 +42,7 @@ class ArticleImportCommand extends Command public function __construct(ArticleImportInterface $articleImporter, ?LoggerInterface $logger = null) { - parent::__construct(); + parent::__construct(static::$defaultName); $this->articleImporter = $articleImporter; $this->logger = $logger ?: new NullLogger(); diff --git a/Command/ReindexCommand.php b/Command/ReindexCommand.php index 57a94a91..ca15552a 100644 --- a/Command/ReindexCommand.php +++ b/Command/ReindexCommand.php @@ -30,6 +30,11 @@ */ class ReindexCommand extends Command { + /** + * @var string + */ + protected static $defaultName = 'sulu:article:reindex'; + /** * @var WebspaceManagerInterface */ @@ -68,7 +73,7 @@ public function __construct( IndexerInterface $liveIndexer, string $suluContext ) { - parent::__construct('sulu:article:reindex'); + parent::__construct(static::$defaultName); $this->webspaceManager = $webspaceManager; $this->propertyEncoder = $propertyEncoder; $this->documentManager = $documentManager; From 312a73f193644c6bb07b9b8e5d42827e77ae0b82 Mon Sep 17 00:00:00 2001 From: Alexander Schranz Date: Wed, 17 Jul 2024 09:28:40 +0200 Subject: [PATCH 8/9] Upgrade some actions --- .github/workflows/test-application.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test-application.yaml b/.github/workflows/test-application.yaml index da423343..e58b29ae 100644 --- a/.github/workflows/test-application.yaml +++ b/.github/workflows/test-application.yaml @@ -139,7 +139,7 @@ jobs: steps: - name: Checkout project - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Install and configure PHP uses: shivammathur/setup-php@v2 @@ -158,7 +158,7 @@ jobs: run: composer require --dev elasticsearch/elasticsearch:"${{ matrix.elasticsearch-package-constraint }}" --no-interaction --no-update - name: Install composer dependencies - uses: ramsey/composer-install@v1 + uses: ramsey/composer-install@v2 with: dependency-versions: ${{matrix.dependency-versions}} composer-options: ${{ matrix.composer-options }} @@ -180,7 +180,7 @@ jobs: steps: - name: Checkout project - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Install and configure PHP uses: shivammathur/setup-php@v2 @@ -194,7 +194,7 @@ jobs: run: composer require --dev elasticsearch/elasticsearch:"~7.11.0" --no-interaction --no-update - name: Install composer dependencies - uses: ramsey/composer-install@v1 + uses: ramsey/composer-install@v2 with: dependency-versions: ${{matrix.dependency-versions}} composer-options: ${{ matrix.composer-options }} From b847fabf76a565f8d0ec9884fb4b18bd70c5b53b Mon Sep 17 00:00:00 2001 From: Alexander Schranz Date: Wed, 17 Jul 2024 09:38:27 +0200 Subject: [PATCH 9/9] Fix code style and change CI --- .github/workflows/test-application.yaml | 2 +- Command/ArticleExportCommand.php | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/test-application.yaml b/.github/workflows/test-application.yaml index e58b29ae..fa5fbcc0 100644 --- a/.github/workflows/test-application.yaml +++ b/.github/workflows/test-application.yaml @@ -85,7 +85,7 @@ jobs: - php-version: '8.3' elasticsearch-version: '7.17.2' elasticsearch-package-constraint: '~7.17.0' - phpcr-transport: jackrabbit + phpcr-transport: doctrinedbal dependency-versions: 'highest' php-extensions: 'ctype, iconv, mysql, imagick' tools: 'composer:v2' diff --git a/Command/ArticleExportCommand.php b/Command/ArticleExportCommand.php index 65b37d7f..7c838155 100644 --- a/Command/ArticleExportCommand.php +++ b/Command/ArticleExportCommand.php @@ -12,7 +12,6 @@ namespace Sulu\Bundle\ArticleBundle\Command; use Sulu\Bundle\ArticleBundle\Export\ArticleExportInterface; -use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface;