8000 bug #59185 [DoctrineBridge] Fix compatibility to Doctrine persistence… · symfony/symfony@02cafa9 · GitHub
[go: up one dir, main page]

Skip to content

Commit 02cafa9

Browse files
committed
bug #59185 [DoctrineBridge] Fix compatibility to Doctrine persistence 2.5 in Doctrine Bridge 6.4 to avoid Projects stuck on 6.3 (alexander-schranz)
This PR was squashed before being merged into the 6.4 branch. Discussion ---------- [DoctrineBridge] Fix compatibility to Doctrine persistence 2.5 in Doctrine Bridge 6.4 to avoid Projects stuck on 6.3 | Q | A | ------------- | --- | Branch? | 6.4 | Bug fix? | yes | New feature? | no <!-- please update src/**/CHANGELOG.md files --> | Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files --> | Issues | Fix #... <!-- prefix each issue number with "Fix #", no need to create an issue if none exists, explain below instead --> | License | MIT Doctrine Bridge dropped support of persistence 2 from 6.3 to 6.4 but I could not yet find out why. (0d4e2b8). It making lot of things harder and get projects stuck on 6.3 which can not yet update doctrine/persistence because of some bc breaks (mostly `Bundle:Entity` syntax). It makes also eco system a little bit harder (doctrine/DoctrineBundle#1841, doctrine/DoctrineFixturesBundle#486, https://github.com/sulu/sulu/actions/runs/12050408254/job/34248387939) as with some changes in symfony and doctrine bundles things get downgraded to symfony 5.4 instead keep in 6.3. If there is any easy way to support persistence 2.5 still on 6.4 bridge I think things would get easier. Want with this PR check what fails on the CI if still allow persistence 2.5. --- Update: Looks like with a few checkst we could get lowest run on persistence 2.5 which would so make easier projects upgrade to Symfony 6.4 without they have to tackle the persistence update in the same case. Commits ------- df3cef8 [DoctrineBridge] Fix compatibility to Doctrine persistence 2.5 in Doctrine Bridge 6.4 to avoid Projects stuck on 6.3
2 parents 8529b41 + df3cef8 commit 02cafa9

File tree

6 files changed

+15
-6
lines changed

6 files changed

+15
-6
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
"ext-xml": "*",
4040
"friendsofphp/proxy-manager-lts": "^1.0.2",
4141
"doctrine/event-manager": "^1.2|^2",
42-
"doctrine/persistence": "^3.1",
42+
"doctrine/persistence": "^2.5|^3.1",
4343
"twig/twig": "^2.13|^3.0.4",
4444
"psr/cache": "^2.0|^3.0",
4545
"psr/clock": "^1.0",

src/Symfony/Bridge/Doctrine/Tests/DoctrineTestHelper.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,10 @@ public static function createTestConfiguration(): Configuration
6161
if (class_exists(DefaultSchemaManagerFactory::class)) {
6262
$config->setSchemaManagerFactory(new DefaultSchemaManagerFactory());
6363
}
64-
$config->setLazyGhostObjectEnabled(true);
64+
65+
if (!class_exists(\Doctrine\Persistence\Mapping\Driver\AnnotationDriver::class)) { // doctrine/persistence >= 3.0
66+
$config->setLazyGhostObjectEnabled(true);
67+
}
6568

6669
return $config;
6770
}

src/Symfony/Bridge/Doctrine/Tests/Middleware/Debug/MiddlewareTest.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,9 @@ private function init(bool $withStopwatch = true): void
5555
if (class_exists(DefaultSchemaManagerFactory::class)) {
5656
$config->setSchemaManagerFactory(new DefaultSchemaManagerFactory());
5757
}
58-
$config->setLazyGhostObjectEnabled(true);
58+
if (!class_exists(\Doctrine\Persistence\Mapping\Driver\AnnotationDriver::class)) { // doctrine/persistence >= 3.0
59+
$config->setLazyGhostObjectEnabled(true);
60+
}
5961
$this->debugDataHolder = new DebugDataHolder();
6062
$config->setMiddlewares([new Middleware($this->debugDataHolder, $this->stopwatch)]);
6163

src/Symfony/Bridge/Doctrine/Tests/PropertyInfo/DoctrineExtractorTest.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,9 @@ private function createExtractor(): DoctrineExtractor
4444
if (class_exists(DefaultSchemaManagerFactory::class)) {
4545
$config->setSchemaManagerFactory(new DefaultSchemaManagerFactory());
4646
}
47-
$config->setLazyGhostObjectEnabled(true);
47+
if (!class_exists(\Doctrine\Persistence\Mapping\Driver\AnnotationDriver::class)) { // doctrine/persistence >= 3.0
48+
$config->setLazyGhostObjectEnabled(true);
49+
}
4850

4951
$eventManager = new EventManager();
5052
$entityManager = new EntityManager(DriverManager::getConnection(['driver' => 'pdo_sqlite'], $config, $eventManager), $config, $eventManager);

src/Symfony/Bridge/Doctrine/Tests/Security/RememberMe/DoctrineTokenProviderTest.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,9 @@ protected function bootstrapProvider(): DoctrineTokenProvider
124124
$config->setSchemaManagerFactory(new DefaultSchemaManagerFactory());
125125
}
126126

127-
$config->setLazyGhostObjectEnabled(true);
127+
if (!class_exists(\Doctrine\Persistence\Mapping\Driver\AnnotationDriver::class)) { // doctrine/persistence >= 3.0
128+
$config->setLazyGhostObjectEnabled(true);
129+
}
128130

129131
$connection = DriverManager::getConnection([
130132
'driver' => 'pdo_sqlite',

src/Symfony/Bridge/Doctrine/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"require": {
1919
"php": ">=8.1",
2020
"doctrine/event-manager": "^1.2|^2",
21-
"doctrine/persistence": "^3.1",
21+
"doctrine/persistence": "^2.5|^3.1",
2222
"symfony/deprecation-contracts": "^2.5|^3",
2323
"symfony/polyfill-ctype": "~1.8",
2424
"symfony/polyfill-mbstring": "~1.0",

0 commit comments

Comments
 (0)
0