Skip to content

Commit f2b8a41

Browse files
authored
Merge pull request #2063 from greg0ire/3.0.x
Merge 2.17.x up into 3.0.x
2 parents dde8f76 + 70d7b14 commit f2b8a41

File tree

7 files changed

+63
-56
lines changed

7 files changed

+63
-56
lines changed

UPGRADE-2.17.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ deprecated. You should stop using it as soon as you upgrade to Doctrine ORM 3.
1414
This option is a no-op when using `doctrine/dbal` 4 and has been conditionally
1515
deprecated. You should stop using it as soon as you upgrade to Doctrine DBAL 4.
1616

17+
### The `doctrine.dbal.connections.some_connection.use_savepoints` configuration option is deprecated
18+
19+
This option is a no-op when using `doctrine/dbal` 4 and has been conditionally
20+
deprecated. You should stop using it as soon as you upgrade to Doctrine DBAL 4.
21+
1722
ConnectionFactory::createConnection() signature change
1823
------------------------------------------------------
1924

composer.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,20 +31,19 @@
3131
"require": {
3232
"php": "^8.4",
3333
"doctrine/dbal": "^4.0",
34+
"doctrine/deprecations": "^1.0",
3435
"doctrine/persistence": "^4",
3536
"doctrine/sql-formatter": "^1.0.1",
3637
"symfony/cache": "^6.4 || ^7.0",
3738
"symfony/config": "^6.4 || ^7.0",
3839
"symfony/console": "^6.4 || ^7.0",
3940
"symfony/dependency-injection": "^6.4 || ^7.0",
40-
"symfony/deprecation-contracts": "^3",
4141
"symfony/doctrine-bridge": "^6.4.3 || ^7.0.3",
4242
"symfony/framework-bundle": "^6.4 || ^7.0",
4343
"symfony/service-contracts": "^3"
4444
},
4545
"require-dev": {
4646
"doctrine/coding-standard": "^13",
47-
"doctrine/deprecations": "^1.0",
4847
"doctrine/orm": "^3.4.4",
4948
"phpstan/phpstan": "2.1.1",
5049
"phpstan/phpstan-phpunit": "2.0.3",

src/DependencyInjection/Compiler/CacheSchemaSubscriberPass.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
use Symfony\Component\DependencyInjection\Reference;
1111

1212
/**
13-
* Injects Doctrine DBAL and legacy PDO adapters into their schema subscribers.
13+
* Injects Doctrine DBAL adapters into their schema subscriber.
1414
*
1515
* Must be run later after ResolveChildDefinitionsPass.
1616
*

src/DependencyInjection/Configuration.php

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
namespace Doctrine\Bundle\DoctrineBundle\DependencyInjection;
66

7+
use Doctrine\DBAL\Connection;
8+
use Doctrine\Deprecations\Deprecation;
79
use Doctrine\ORM\EntityManager;
810
use Doctrine\ORM\EntityRepository;
911
use Doctrine\ORM\Mapping\ClassMetadata;
@@ -29,6 +31,7 @@
2931
use function is_array;
3032
use function is_string;
3133
use function key;
34+
use function method_exists;
3235
use function reset;
3336
use function sprintf;
3437
use function strtoupper;
@@ -316,7 +319,21 @@ private function configureDbalDriverNode(ArrayNodeDefinition $node): void
316319
->end()
317320
->booleanNode('pooled')->info('True to use a pooled server with the oci8/pdo_oracle driver')->end()
318321
->booleanNode('MultipleActiveResultSets')->info('Configuring MultipleActiveResultSets for the pdo_sqlsrv driver')->end()
319-
->booleanNode('use_savepoints')->info('Use savepoints for nested transactions')->end()
322+
->booleanNode('use_savepoints')
323+
->info('Use savepoints for nested transactions')
324+
->beforeNormalization()
325+
->ifTrue(static fn ($v): bool => isset($v) && ! method_exists(Connection::class, 'getEventManager'))
326+
->then(static function ($v) {
327+
Deprecation::trigger(
328+
'doctrine/doctrine-bundle',
329+
'https://github.com/doctrine/DoctrineBundle/pull/2055',
330+
'The "use_savepoints" configuration key is deprecated when using DBAL 4 and will be removed in DoctrineBundle 3.0.',
331+
);
332+
333+
return $v;
334+
})
335+
->end()
336+
->end()
320337
->scalarNode('instancename')
321338
->info(
322339
'Optional parameter, complete whether to add the INSTANCE_NAME parameter in the connection.' .

tests/DependencyInjection/DoctrineExtensionTest.php

Lines changed: 19 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,6 @@
6565

6666
class DoctrineExtensionTest extends TestCase
6767
{
68-
/**
69-
* https://github.com/doctrine/orm/pull/7953 needed, otherwise ORM classes
70-
* we define services for trigger deprecations
71-
*/
72-
#[IgnoreDeprecations]
7368
public function testAutowiringAlias(): void
7469
{
7570
if (! interface_exists(EntityManagerInterface::class)) {
@@ -505,6 +500,7 @@ public function testDependencyInjectionConfigurationDefaults(): void
505500
$this->assertSame(ArrayAdapter::class, $definition->getClass());
506501
}
507502

503+
#[IgnoreDeprecations]
508504
public function testUseSavePointsAddMethodCallToAddSavepointsToTheConnection(): void
509505
{
510506
$container = $this->getContainer();
@@ -929,51 +925,6 @@ public function testCacheConfiguration(string $expectedAliasName, string $expect
929925
$this->assertEquals($expectedTarget, (string) $alias);
930926
}
931927

932-
/** @param array{type: ?string, pool?: string, id?: string} $cacheConfig */
933-
#[DataProvider('legacyCacheConfigurationProvider')]
934-
#[IgnoreDeprecations]
935-
public function testLegacyCacheConfiguration(string $expectedAliasName, string $expectedAliasTarget, string $cacheName, array $cacheConfig): void
936-
{
937-
$this->testCacheConfiguration($expectedAliasName, $expectedAliasTarget, $cacheName, $cacheConfig);
938-
}
939-
940-
/** @return array<string, array{expectedAliasName: string, expectedAliasTarget: string, cacheName: string, cacheConfig: array{type: ?string, pool?: string, id?: string}}> */
941-
public static function legacyCacheConfigurationProvider(): array
942-
{
943-
return [
944-
'metadata_cache_default' => [
945-
'expectedAliasName' => 'doctrine.orm.default_metadata_cache',
946-
'expectedAliasTarget' => 'cache.doctrine.orm.default.metadata',
947-
'cacheName' => 'metadata_cache_driver',
948-
'cacheConfig' => ['type' => null],
949-
],
950-
'metadata_cache_pool' => [
951-
'expectedAliasName' => 'doctrine.orm.default_metadata_cache',
952-
'expectedAliasTarget' => 'metadata_cache_pool',
953-
'cacheName' => 'metadata_cache_driver',
954-
'cacheConfig' => ['type' => 'pool', 'pool' => 'metadata_cache_pool'],
955-
],
956-
'metadata_cache_service' => [
957-
'expectedAliasName' => 'doctrine.orm.default_metadata_cache',
958-
'expectedAliasTarget' => 'service_target_metadata',
959-
'cacheName' => 'metadata_cache_driver',
960-
'cacheConfig' => ['type' => 'service', 'id' => 'service_target_metadata'],
961-
],
962-
'query_cache_service' => [
963-
'expectedAliasName' => 'doctrine.orm.default_query_cache',
964-
'expectedAliasTarget' => 'service_target_query',
965-
'cacheName' => 'query_cache_driver',
966-
'cacheConfig' => ['type' => 'service', 'id' => 'service_target_query'],
967-
],
968-
'result_cache_service' => [
969-
'expectedAliasName' => 'doctrine.orm.default_result_cache',
970-
'expectedAliasTarget' => 'service_target_result',
971-
'cacheName' => 'result_cache_driver',
972-
'cacheConfig' => ['type' => 'service', 'id' => 'service_target_result'],
973-
],
974-
];
975-
}
976-
977928
/** @return array<string, array<string, string|array{type: ?string, pool?: string, id?: string}>> */
978929
public static function cacheConfigurationProvider(): array
979930
{
@@ -1014,6 +965,24 @@ public static function cacheConfigurationProvider(): array
1014965
'cacheName' => 'result_cache_driver',
1015966
'cacheConfig' => ['type' => 'service', 'id' => 'service_target_result'],
1016967
],
968+
'metadata_cache_default' => [
969+
'expectedAliasName' => 'doctrine.orm.default_metadata_cache',
970+
'expectedTarget' => 'cache.doctrine.orm.default.metadata',
971+
'cacheName' => 'metadata_cache_driver',
972+
'cacheConfig' => ['type' => null],
973+
],
974+
'metadata_cache_pool' => [
975+
'expectedAliasName' => 'doctrine.orm.default_metadata_cache',
976+
'expectedTarget' => 'metadata_cache_pool',
977+
'cacheName' => 'metadata_cache_driver',
978+
'cacheConfig' => ['type' => 'pool', 'pool' => 'metadata_cache_pool'],
979+
],
980+
'metadata_cache_service' => [
981+
'expectedAliasName' => 'doctrine.orm.default_metadata_cache',
982+
'expectedTarget' => 'service_target_metadata',
983+
'cacheName' => 'metadata_cache_driver',
984+
'cacheConfig' => ['type' => 'service', 'id' => 'service_target_metadata'],
985+
],
1017986
];
1018987
}
1019988

@@ -1382,8 +1351,6 @@ public function testControllerResolver(bool $simpleEntityManagerConfig): void
13821351
$this->assertEquals(new MapEntity(null, null, null, null, null, null, null, true, true), $container->get('controller_resolver_defaults'));
13831352
}
13841353

1385-
// phpcs:enable
1386-
13871354
/** @param list<string> $bundles */
13881355
private static function getContainer(array $bundles = ['XmlBundle'], string $vendor = ''): ContainerBuilder
13891356
{
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?xml version="1.0" encoding="UTF-8" ?>
2+
<container xmlns="http://symfony.com/schema/dic/services"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xmlns:doctrine="http://symfony.com/schema/dic/doctrine"
5+
xsi:schemaLocation="http://symfony.com/schema/dic/services https://symfony.com/schema/dic/services/services-1.0.xsd
6+
http://symfony.com/schema/dic/doctrine https://symfony.com/schema/dic/doctrine/doctrine-1.0.xsd">
7+
8+
<doctrine:config>
9+
<doctrine:dbal default-connection="savepoints">
10+
<doctrine:connection name="savepoints" use-savepoints="true" />
11+
</doctrine:dbal>
12+
</doctrine:config>
13+
</container>
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
doctrine:
2+
dbal:
3+
default_connection: savepoints
4+
connections:
5+
savepoints:
6+
use_savepoints: true

0 commit comments

Comments
 (0)