Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build with php 8.3 and symfony 7 dev #387

Merged
merged 3 commits into from
Jan 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 14 additions & 14 deletions .github/workflows/test-application.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,16 @@ jobs:
test:
name: "PHP ${{ matrix.php-version }}, Symfony ${{ matrix.symfony-version }}"
runs-on: "ubuntu-20.04"
env:
SYMFONY_REQUIRE: ${{matrix.symfony-require}}

strategy:
fail-fast: false
matrix:
include:
- php-version: "7.4"
phpunit-version: "8.5"
dependencies: "lowest"

- php-version: "7.4"
phpunit-version: "8.5"
phpunit-flags: "-v --coverage-text"
symfony-version: "^5.4"

- php-version: "8.0"
- php-version: "8.1"
phpunit-version: "9.5"
phpunit-flags: "-v --coverage-text"
symfony-version: "6.0.*"

- php-version: "8.1"
Expand All @@ -36,9 +30,13 @@ jobs:
- php-version: "8.2"
phpunit-version: "9.5"

- php-version: "8.3"
phpunit-version: "9.5"
symfony-version: "7.*"

steps:
- name: "Checkout project"
uses: "actions/checkout@v3"
uses: "actions/checkout@v4"

- name: "Install and configure PHP"
uses: "shivammathur/setup-php@v2"
Expand All @@ -47,11 +45,13 @@ jobs:
extensions: "pdo, pdo_sqlite"
tools: "composer:v2"

- name: "Require Specific Symfony Version"
- name: "Require specific symfony version"
if: "${{ matrix.symfony-version }}"
run: "composer require --no-update symfony/symfony:${{ matrix.symfony-version }}"
run: |
composer require --no-update symfony/flex
composer config --no-plugins allow-plugins.symfony/flex true

- name: "Require Additional dependencies"
- name: "Require additional dependencies"
if: "${{ matrix.composer-require }}"
run: "composer require --no-update ${{ matrix.composer-require }}"

Expand Down
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@ Changelog

* Upgrade to phpcr-odm 2.0
* Support jackalope 2.0
* Drop support for PHP 7
* Replace doctrine cache with PSR-6 cache with the symfony/cache implementation.
The configuration of metadata_cache_driver changed. By default, it creates an `array` cache.
To configure a service, specify `type: service` and specify your service in the `id` property.
To use a cache pool, specify the service id of that pool.
* Removed support for namespace alias, use the FQN names.
* Introduced the ManagerRegistryInterface for the ManagerRegistry and adjusted the service alias for autowiring to the interface.
* The following container parameters are no longer taken into account (memcache and apc seem to have never been used anyways).
If you have customised the array cache class, please check if this is still needed - and note that starting from this version,
Expand All @@ -26,6 +28,7 @@ Changelog
doctrine_phpcr.odm.cache.memcached_port
doctrine_phpcr.odm.cache.memcached_instance.class
doctrine_phpcr.odm.cache.xcache.class

* If no username is defined for a session, and if you use Jackalope >= 2.0, the
credentials service for this session is no longer created and `null` is
passed as credentials.
Expand Down
45 changes: 25 additions & 20 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,36 +21,40 @@
}
],
"require": {
"php": "^7.4 || ^8.0",
"phpcr/phpcr-utils": "^1.3",
"symfony/doctrine-bridge": "^5.4 || ^6.0",
"symfony/framework-bundle": "^5.4 || ^6.0",
"symfony/cache": "^5.4 || ^6.0"
"php": "^8.0",
"ext-dom": "*",
"phpcr/phpcr-utils": "^1.3 || ^2.0",
"symfony/cache": "^5.4 || ^6.0 || ^7.0",
"symfony/doctrine-bridge": "^5.4 || ^6.0 || ^7.0",
"symfony/framework-bundle": "^5.4 || ^6.0 || ^7.0"
},
"conflict": {
"doctrine/annotations": "< 1.7.0",
"doctrine/doctrine-bundle": "< 2.0.3",
"jackalope/jackalope": "< 1.3.1",
"phpcr/phpcr-shell": "< 1.0.0-beta1"
"phpcr/phpcr-shell": "< 1.0.0-beta1",
"symfony/dependency-injection": "< 3",
"symfony/console": "< 4"
},
"require-dev": {
"doctrine/doctrine-bundle": "^2.0.3",
"doctrine/phpcr-odm": "^2.0",
"jackalope/jackalope-doctrine-dbal": "^1.3 || ^2.0",
"matthiasnoback/symfony-dependency-injection-test": "^4.1",
"symfony/asset": "^5.4 || ^6.0",
"symfony/browser-kit": "^5.4 || ^6.0",
"symfony/css-selector": "^5.4 || ^6.0",
"symfony/error-handler": "^4.4 || ^5.0 || ^6.0",
"symfony/form": "^5.4 || ^6.0",
"symfony/monolog-bridge": "^5.4 || ^6.0",
"doctrine/phpcr-odm": "2.x-dev",
"doctrine/orm": "^2.0 || ^3.0",
"jackalope/jackalope-doctrine-dbal": "^2.0",
"matthiasnoback/symfony-dependency-injection-test": "^4.3.1 || ^5.0",
"symfony/asset": "^5.4 || ^6.0 || ^7.0",
"symfony/browser-kit": "^5.4 || ^6.0 || ^7.0",
"symfony/css-selector": "^5.4 || ^6.0 || ^7.0",
"symfony/error-handler": "^5.4 || ^6.0 || ^7.0",
"symfony/form": "^5.4 || ^6.0 || ^7.0",
"symfony/monolog-bridge": "^5.4 || ^6.0 || ^7.0",
"symfony/monolog-bundle": "^3.4",
"symfony/phpunit-bridge": "^v6.4.2 || ^v7.0.2",
"symfony/templating": "^5.4 || ^6.0",
"symfony/translation": "^5.4 || ^6.0",
"symfony/twig-bundle": "^5.4 || ^6.0",
"symfony/validator": "^5.4 || ^6.0",
"symfony/web-profiler-bundle": "^5.4 || ^6.0"
"symfony/templating": "^5.4 || ^6.0 || ^7.0",
"symfony/translation": "^5.4 || ^6.0 || ^7.0",
"symfony/twig-bundle": "^5.4 || ^6.0 || ^7.0",
"symfony/validator": "^5.4 || ^6.0 || ^7.0",
"symfony/web-profiler-bundle": "^5.4 || ^6.0 || ^7.0"
},
"suggest": {
"burgov/key-value-form-bundle": "to edit assoc multivalue properties. require version 1.0.*",
Expand Down Expand Up @@ -78,5 +82,6 @@
"Doctrine\\Bundle\\PHPCRBundle\\Tests\\": "tests/"
}
},
"prefer-stable": true,
"minimum-stability": "beta"
}
4 changes: 3 additions & 1 deletion src/CacheWarmer/UniqueNodeTypeCacheWarmer.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,14 @@ public function isOptional(): bool
return true;
}

public function warmUp($cacheDir): void
public function warmUp(string $cacheDir, ?string $buildDir = null): array
{
$helper = new UniqueNodeTypeHelper();

foreach ($this->registry->getManagers() as $documentManager) {
$helper->checkNodeTypeMappings($documentManager);
}

return [];
}
}
68 changes: 35 additions & 33 deletions src/Command/LoadFixtureCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,17 @@
namespace Doctrine\Bundle\PHPCRBundle\Command;

use Doctrine\Bundle\PHPCRBundle\DataFixtures\PHPCRExecutor;
use Doctrine\Bundle\PHPCRBundle\Initializer\InitializerManager;
use Doctrine\Common\DataFixtures\Loader;
use Doctrine\Common\DataFixtures\Purger\PHPCRPurger;
use Doctrine\ODM\PHPCR\Tools\Console\Helper\DocumentManagerHelper;
use InvalidArgumentException;
use Symfony\Bridge\Doctrine\DataFixtures\ContainerAwareLoader;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Helper\DialogHelper;
use Symfony\Component\Console\Helper\QuestionHelper;
use PHPCR\Util\Console\Command\BaseCommand;
use Symfony\Bundle\FrameworkBundle\Console\Application;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Question\ConfirmationQuestion;
use Symfony\Component\DependencyInjection\ContainerAwareTrait;
use Symfony\Component\HttpKernel\KernelInterface;

/**
* Command to load PHPCR-ODM fixtures.
Expand All @@ -24,14 +23,20 @@
* @author Jonathan H. Wage <[email protected]>
* @author Daniel Leech <[email protected]>
*/
class LoadFixtureCommand extends Command
class LoadFixtureCommand extends BaseCommand
{
use ContainerAwareTrait;
private const NAME = 'doctrine:phpcr:fixtures:load';

public function __construct(
private InitializerManager $initializerManager
) {
parent::__construct(self::NAME);
}

protected function configure(): void
{
$this
->setName('doctrine:phpcr:fixtures:load')
->setName(self::NAME)
->setDescription('Load data fixtures to your PHPCR database.')
->addOption('fixtures', null, InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'The directory or file to load data fixtures from.')
->addOption('append', null, InputOption::VALUE_NONE, 'Append the data fixtures to the existing data - will not purge the workspace.')
Expand Down Expand Up @@ -65,28 +70,24 @@ protected function configure(): void
protected function execute(InputInterface $input, OutputInterface $output): int
{
$dmName = $input->getOption('dm'); // defaults to null
$application = $this->getApplication();
if (!$application instanceof Application) {
throw new \InvalidArgumentException('Expected to find '.Application::class.' but got '.
($application ? \get_class($application) : null));
}
DoctrineCommandHelper::setApplicationDocumentManager(
$this->getApplication(),
$application,
$dmName
);

$dm = $this->getHelperSet()->get('phpcr')->getDocumentManager();
$dm = $this->getPhpcrHelper()->getDocumentManager();
$noInitialize = $input->getOption('no-initialize');

if ($input->isInteractive() && !$input->getOption('append')) {
$question = '<question>Careful, database will be purged. Do you want to continue Y/N ?</question>';
$default = false;
if ($this->getHelperSet()->has('question')) {
/** @var $questionHelper QuestionHelper */
$questionHelper = $this->getHelperSet()->get('question');
$question = new ConfirmationQuestion($question, $default);
$result = $questionHelper->ask($input, $output, $question);
} else {
/** @var $dialog DialogHelper */
$dialog = $this->getHelperSet()->get('dialog');
$result = $dialog->askConfirmation($output, $question, $default);
}

$questionHelper = $this->getQuestionHelper();
$question = new ConfirmationQuestion($question, false);
$result = $questionHelper->ask($input, $output, $question);
if (!$result) {
return 0;
}
Expand All @@ -96,16 +97,15 @@ protected function execute(InputInterface $input, OutputInterface $output): int
if ($dirOrFile) {
$paths = \is_array($dirOrFile) ? $dirOrFile : [$dirOrFile];
} else {
/** @var $kernel KernelInterface */
$kernel = $this->getApplication()->getKernel();
$kernel = $application->getKernel();
$projectDir = method_exists($kernel, 'getRootDir') ? $kernel->getRootDir() : $kernel->getProjectDir().'/src';
$paths = [$projectDir.'/DataFixtures/PHPCR'];
foreach ($kernel->getBundles() as $bundle) {
$paths[] = $bundle->getPath().'/DataFixtures/PHPCR';
}
}

$loader = new ContainerAwareLoader($this->container);
$loader = new Loader();
foreach ($paths as $path) {
if (is_dir($path)) {
$loader->loadFromDirectory($path);
Expand All @@ -123,18 +123,20 @@ protected function execute(InputInterface $input, OutputInterface $output): int

$purger = new PHPCRPurger($dm);

if ($noInitialize) {
$initializerManager = null;
} else {
$initializerManager = $this->container->get('doctrine_phpcr.initializer_manager');
}

$executor = new PHPCRExecutor($dm, $purger, $initializerManager);
$executor = new PHPCRExecutor($dm, $purger, $noInitialize ? null : $this->initializerManager);
$executor->setLogger(function ($message) use ($output) {
$output->writeln(sprintf(' <comment>></comment> <info>%s</info>', $message));
});
$executor->execute($fixtures, $input->getOption('append'));

return 0;
}

protected function getPhpcrHelper(): DocumentManagerHelper
{
$helper = parent::getPhpcrHelper();
\assert($helper instanceof DocumentManagerHelper);

return $helper;
}
}
31 changes: 23 additions & 8 deletions src/Command/MigratorMigrateCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,29 @@

namespace Doctrine\Bundle\PHPCRBundle\Command;

use Symfony\Component\Console\Command\Command;
use Doctrine\Bundle\PHPCRBundle\Migrator\MigratorInterface;
use PHPCR\Util\Console\Command\BaseCommand;
use Symfony\Bundle\FrameworkBundle\Console\Application;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\DependencyInjection\ContainerAwareTrait;
use Symfony\Component\DependencyInjection\ContainerInterface;

class MigratorMigrateCommand extends Command
class MigratorMigrateCommand extends BaseCommand
{
use ContainerAwareTrait;
private const NAME = 'doctrine:phpcr:migrator:migrate';

public function __construct(
private ContainerInterface $container
) {
parent::__construct(self::NAME);
}

protected function configure(): void
{
$this
->setName('doctrine:phpcr:migrator:migrate')
->setName(self::NAME)
->setDescription('Migrates PHPCR data.')
->addArgument('migrator_name', InputArgument::OPTIONAL, 'The name of the alias/service to be used to migrate the data.')
->addOption('identifier', null, InputOption::VALUE_REQUIRED, 'Path or UUID of the node to migrate', '/')
Expand All @@ -31,11 +39,16 @@ protected function configure(): void

protected function execute(InputInterface $input, OutputInterface $output): int
{
$application = $this->getApplication();
if (!$application instanceof Application) {
throw new \InvalidArgumentException('Expected to find '.Application::class.' but got '.
($application ? \get_class($application) : null));
}
DoctrineCommandHelper::setApplicationPHPCRSession(
$this->getApplication(),
$application,
$input->getOption('session')
);
$session = $this->getHelperSet()->get('phpcr')->getSession();
$session = $this->getPhpcrSession();

$migrators = $this->container->getParameter('doctrine_phpcr.migrate.migrators');

Expand All @@ -53,7 +66,9 @@ protected function execute(InputInterface $input, OutputInterface $output): int
}

$migrator = $this->container->get($id);

if (!$migrator instanceof MigratorInterface) {
throw new \InvalidArgumentException('Looked for a '.MigratorInterface::class.' but found '.($migrator ? \get_class($migrator) : $migrator));
}
$migrator->init($session, $output);

$identifier = $input->getOption('identifier');
Expand Down
Loading