Skip to content

Commit

Permalink
Add support for Symfony 7 and Jackalope 2 (#684)
Browse files Browse the repository at this point in the history
* Upgrade to Symfony 7

* Fix jackalope 2 compatibility

* Allow installation of jms serializer bundel 5

* Test Symfony 7 branch

* Test support for PHP 8.4

* Apply suggestions from code review

* Fix lint commands

* Upgrade some actions

* Fix code style and change CI
  • Loading branch information
alexander-schranz authored Jul 17, 2024
1 parent 343d441 commit 264ef11
Show file tree
Hide file tree
Showing 7 changed files with 61 additions and 33 deletions.
33 changes: 24 additions & 9 deletions .github/workflows/test-application.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,22 @@ jobs:
ELASTICSEARCH_HOST: '127.0.0.1:9200'

- php-version: '8.3'
elasticsearch-version: '7.11.1'
elasticsearch-package-constraint: '~7.11.0'
phpcr-transport: jackrabbit
elasticsearch-version: '7.17.2'
elasticsearch-package-constraint: '~7.17.0'
phpcr-transport: doctrinedbal
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'
tools: 'composer:v2'
Expand Down Expand Up @@ -126,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
Expand All @@ -136,14 +149,16 @@ 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

- 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 }}
Expand All @@ -165,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
Expand All @@ -179,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 }}
Expand Down
9 changes: 6 additions & 3 deletions Command/ArticleExportCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@

class ArticleExportCommand extends Command
{
/**
* @var string
*/
protected static $defaultName = 'sulu:article:export';

/**
Expand All @@ -30,20 +33,20 @@ class ArticleExportCommand extends Command

public function __construct(ArticleExportInterface $articleExporter)
{
parent::__construct();
parent::__construct(static::$defaultName);

$this->articleExporter = $articleExporter;
}

protected function configure()
protected function configure(): void
{
$this->addArgument('target', InputArgument::REQUIRED, 'export.xliff')
->addArgument('locale', InputArgument::REQUIRED)
->addOption('format', 'f', InputOption::VALUE_REQUIRED, '', '1.2.xliff')
->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, '/')) {
Expand Down
9 changes: 6 additions & 3 deletions Command/ArticleImportCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@

class ArticleImportCommand extends Command
{
/**
* @var string
*/
protected static $defaultName = 'sulu:article:import';

/**
Expand All @@ -39,13 +42,13 @@ 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();
}

protected function configure()
protected function configure(): void
{
$this->addArgument('file', InputArgument::REQUIRED, 'export.xliff')
->addArgument('locale', InputArgument::REQUIRED)
Expand All @@ -55,7 +58,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, '/')) {
Expand Down
11 changes: 8 additions & 3 deletions Command/ReindexCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@
*/
class ReindexCommand extends Command
{
/**
* @var string
*/
protected static $defaultName = 'sulu:article:reindex';

/**
* @var WebspaceManagerInterface
*/
Expand Down Expand Up @@ -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;
Expand All @@ -77,15 +82,15 @@ 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.');
$this->addOption('drop', null, InputOption::VALUE_NONE, 'Drop and recreate index before reindex');
$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);

Expand Down
2 changes: 1 addition & 1 deletion DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
*/
class Configuration implements ConfigurationInterface
{
public function getConfigTreeBuilder()
public function getConfigTreeBuilder(): TreeBuilder
{
$treeBuilder = new TreeBuilder('sulu_article');
$rootNode = $treeBuilder->getRootNode();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
Expand Down
26 changes: 13 additions & 13 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,23 +21,23 @@
"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": "^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",
"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",
"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",
Expand All @@ -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",
Expand Down

0 comments on commit 264ef11

Please sign in to comment.