From 210f118a48d9ad419fc319c876249ffd18553b7d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Niedzielski?= Date: Wed, 9 Sep 2026 16:08:58 +0200 Subject: [PATCH 1/2] Deprecated the schema-file API and moved DatabaseSchemaHook onto SchemaApplier DatabaseSchemaHook reimplemented the toSql()-and-execute loop that ibexa/core's LegacySchemaImporter also has; both now use doctrine-schema's SchemaApplier. The hook needs no dropping, since Bootstrapper always hands it a freshly created database. DefaultSchemaFilesProvider and IbexaTestKernel::getSchemaFiles() are deprecated. Nothing in this package reads them any more: the schema comes from SchemaBuilderEvent, so whichever bundles a kernel registers is what the schema contains. They stay because IbexaTestKernelInterface still mandates getSchemaFiles(), and ibexa/core's IbexaKernelTestTrait kept reading it until ibexa/core#823. --- .../RemoveUnsatisfiableHooksPass.php | 2 ++ .../Bootstrapper/DatabaseSchemaHook.php | 16 ++++++---------- .../Bootstrapper/DefaultSchemaFilesProvider.php | 7 +++++++ src/contracts/IbexaTestKernel.php | 7 +++++++ 4 files changed, 22 insertions(+), 10 deletions(-) diff --git a/src/bundle/DependencyInjection/CompilerPass/RemoveUnsatisfiableHooksPass.php b/src/bundle/DependencyInjection/CompilerPass/RemoveUnsatisfiableHooksPass.php index 1c4f0d8..544ba4c 100644 --- a/src/bundle/DependencyInjection/CompilerPass/RemoveUnsatisfiableHooksPass.php +++ b/src/bundle/DependencyInjection/CompilerPass/RemoveUnsatisfiableHooksPass.php @@ -10,6 +10,7 @@ use Ibexa\Bundle\RepositoryInstaller\Event\Subscriber\BuildSchemaSubscriber; use Ibexa\Contracts\Core\Test\Persistence\Fixture\FixtureImporter; +use Ibexa\Contracts\DoctrineSchema\Builder\SchemaApplierInterface; use Ibexa\Contracts\DoctrineSchema\Builder\SchemaBuilderInterface; use Ibexa\Contracts\Test\Core\Bootstrapper\DatabaseSchemaHook; use Ibexa\Contracts\Test\Core\Bootstrapper\FixtureHook; @@ -30,6 +31,7 @@ final class RemoveUnsatisfiableHooksPass implements CompilerPassInterface private const HOOK_REQUIREMENTS = [ DatabaseSchemaHook::class => [ SchemaBuilderInterface::class, + SchemaApplierInterface::class, // core's own schema contribution; without it the event yields every other package's // tables but none of core's BuildSchemaSubscriber::class, diff --git a/src/contracts/Bootstrapper/DatabaseSchemaHook.php b/src/contracts/Bootstrapper/DatabaseSchemaHook.php index 94097f3..066af82 100644 --- a/src/contracts/Bootstrapper/DatabaseSchemaHook.php +++ b/src/contracts/Bootstrapper/DatabaseSchemaHook.php @@ -8,7 +8,7 @@ namespace Ibexa\Contracts\Test\Core\Bootstrapper; -use Doctrine\DBAL\Connection; +use Ibexa\Contracts\DoctrineSchema\Builder\SchemaApplierInterface; use Ibexa\Contracts\DoctrineSchema\Builder\SchemaBuilderInterface; use Symfony\Component\OptionsResolver\OptionsResolver; @@ -33,12 +33,12 @@ final class DatabaseSchemaHook implements HookInterface private SchemaBuilderInterface $schemaBuilder; - private Connection $connection; + private SchemaApplierInterface $schemaApplier; - public function __construct(SchemaBuilderInterface $schemaBuilder, Connection $connection) + public function __construct(SchemaBuilderInterface $schemaBuilder, SchemaApplierInterface $schemaApplier) { $this->schemaBuilder = $schemaBuilder; - $this->connection = $connection; + $this->schemaApplier = $schemaApplier; } public function configureOptions(OptionsResolver $resolver): void @@ -54,11 +54,7 @@ public function __invoke(array $options): void return; } - $schema = $this->schemaBuilder->buildSchema(); - $platform = $this->connection->getDatabasePlatform(); - - foreach ($schema->toSql($platform) as $sql) { - $this->connection->executeStatement($sql); - } + // the test database is always freshly created, so there is nothing to drop first + $this->schemaApplier->applySchema($this->schemaBuilder->buildSchema()); } } diff --git a/src/contracts/Bootstrapper/DefaultSchemaFilesProvider.php b/src/contracts/Bootstrapper/DefaultSchemaFilesProvider.php index 3f03696..538a493 100644 --- a/src/contracts/Bootstrapper/DefaultSchemaFilesProvider.php +++ b/src/contracts/Bootstrapper/DefaultSchemaFilesProvider.php @@ -18,6 +18,13 @@ * class exists purely so another provider can constructor-inject it directly to compose with the * built-in default without going through a Kernel method. */ +/** + * @deprecated since Ibexa 4.6.x, no longer used by anything in this package. It exists only to back + * {@see \Ibexa\Contracts\Test\Core\IbexaTestKernel::getSchemaFiles()}, itself deprecated: + * the test schema is now built from + * {@see \Ibexa\Contracts\DoctrineSchema\Event\SchemaBuilderEvent} rather than from a list + * of raw schema files. Will be removed in 6.0. + */ final class DefaultSchemaFilesProvider { private KernelInterface $kernel; diff --git a/src/contracts/IbexaTestKernel.php b/src/contracts/IbexaTestKernel.php index 603645e..87d0113 100644 --- a/src/contracts/IbexaTestKernel.php +++ b/src/contracts/IbexaTestKernel.php @@ -127,6 +127,13 @@ public static function getAliasServiceId(string $id): string /** * @return iterable + * + * @deprecated since Ibexa 4.6.x. The test schema is built from + * {@see \Ibexa\Contracts\DoctrineSchema\Event\SchemaBuilderEvent} — whichever bundles + * a kernel registers is what the schema contains — so a kernel no longer declares + * schema files, and overriding this serves no purpose. Retained because + * {@see \Ibexa\Contracts\Core\Test\IbexaTestKernelInterface} still mandates it. + * Will be removed in 6.0. */ public function getSchemaFiles(): iterable { From 50d670d50d8ec5e1659901fdcfb102f83bd145a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Niedzielski?= Date: Wed, 9 Sep 2026 16:09:33 +0200 Subject: [PATCH 2/2] TEMPORARY: Added dependencies.json to test against ibexa/doctrine-schema#49 Points CI at the branch that adds SchemaApplier, so this PR's tests can run before that PR merges. Must be removed before merging. --- dependencies.json | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 dependencies.json diff --git a/dependencies.json b/dependencies.json new file mode 100644 index 0000000..838a86c --- /dev/null +++ b/dependencies.json @@ -0,0 +1,11 @@ +{ + "recipesEndpoint": "", + "packages": [ + { + "requirement": "dev-feature/schema-applier-4.6 as 4.6.x-dev", + "repositoryUrl": "https://github.com/ibexa/doctrine-schema.git", + "package": "ibexa/doctrine-schema", + "shouldBeAddedAsVCS": false + } + ] +}