Skip to content

Commit 27e83a1

Browse files
committed
Merge remote-tracking branch 'origin/2.17.x' into 3.0.x
2 parents ae7ca9a + 61c9bf4 commit 27e83a1

3 files changed

Lines changed: 48 additions & 1 deletion

File tree

UPGRADE-2.17.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@ Configuration
99
This option is a no-op when using `doctrine/orm` 3 and has been conditionally
1010
deprecated. You should stop using it as soon as you upgrade to Doctrine ORM 3.
1111

12+
### The `doctrine.dbal.connections.some_connection.disable_type_comments` configuration option is deprecated
13+
14+
This option is a no-op when using `doctrine/dbal` 4 and has been conditionally
15+
deprecated. You should stop using it as soon as you upgrade to Doctrine DBAL 4.
16+
1217
ConnectionFactory::createConnection() signature change
1318
------------------------------------------------------
1419

src/DependencyInjection/Configuration.php

Lines changed: 17 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;
@@ -185,7 +188,20 @@ private function getDbalConnectionsNode(): ArrayNodeDefinition
185188
->defaultValue(true)
186189
->info('Enables collecting schema errors when profiling is enabled')
187190
->end()
188-
->booleanNode('disable_type_comments')->end()
191+
->booleanNode('disable_type_comments')
192+
->beforeNormalization()
193+
->ifTrue(static fn ($v): bool => isset($v) && ! method_exists(Connection::class, 'getEventManager'))
194+
->then(static function ($v) {
195+
Deprecation::trigger(
196+
'doctrine/doctrine-bundle',
197+
'https://github.com/doctrine/DoctrineBundle/pull/2048',
198+
'The "disable_type_comments" configuration key is deprecated when using DBAL 4 and will be removed in DoctrineBundle 3.0.',
199+
);
200+
201+
return $v;
202+
})
203+
->end()
204+
->end()
189205
->scalarNode('server_version')->end()
190206
->integerNode('idle_connection_ttl')->defaultValue(600)->end()
191207
->scalarNode('driver_class')->end()

tests/DependencyInjection/AbstractDoctrineExtensionTestCase.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,10 @@
99
use Doctrine\Bundle\DoctrineBundle\DependencyInjection\DoctrineExtension;
1010
use Doctrine\Bundle\DoctrineBundle\Tests\DependencyInjection\Fixtures\InvokableEntityListener;
1111
use Doctrine\DBAL\Configuration;
12+
use Doctrine\DBAL\Connection;
1213
use Doctrine\DBAL\Connections\PrimaryReadReplicaConnection;
1314
use Doctrine\DBAL\Platforms\PostgreSQLPlatform;
15+
use Doctrine\Deprecations\PHPUnit\VerifyDeprecations;
1416
use Doctrine\ORM\EntityManager;
1517
use Doctrine\ORM\EntityManagerInterface;
1618
use Doctrine\ORM\Mapping\ClassMetadata;
@@ -41,6 +43,7 @@
4143
use function end;
4244
use function interface_exists;
4345
use function is_dir;
46+
use function method_exists;
4447
use function sprintf;
4548
use function sys_get_temp_dir;
4649
use function uniqid;
@@ -49,6 +52,8 @@
4952

5053
abstract class AbstractDoctrineExtensionTestCase extends TestCase
5154
{
55+
use VerifyDeprecations;
56+
5257
abstract protected function loadFromFile(ContainerBuilder $container, string $file): void;
5358

5459
public function testDbalLoadFromXmlMultipleConnections(): void
@@ -795,6 +800,27 @@ public function testAddFilter(): void
795800
$this->assertCount(2, $entityManager->getFilters()->getEnabledFilters());
796801
}
797802

803+
#[IgnoreDeprecations]
804+
public function testSettingDisableTypeCommentsWithDbal4IsDeprecated(): void
805+
{
806+
if (method_exists(Connection::class, 'getEventManager')) {
807+
self::markTestSkipped('This test requires DBAL 4.');
808+
}
809+
810+
$this->expectDeprecationWithIdentifier('https://github.com/doctrine/DoctrineBundle/pull/2048');
811+
$this->loadContainer('dbal_disable_type_comments');
812+
}
813+
814+
public function testSettingDisableTypeCommentsWithDbal3IsFine(): void
815+
{
816+
if (! method_exists(Connection::class, 'getEventManager')) {
817+
self::markTestSkipped('This test requires DBAL 3.');
818+
}
819+
820+
$this->expectNoDeprecationWithIdentifier('https://github.com/doctrine/DoctrineBundle/pull/2048');
821+
$this->loadContainer('dbal_disable_type_comments');
822+
}
823+
798824
public function testResolveTargetEntity(): void
799825
{
800826
if (! interface_exists(EntityManagerInterface::class)) {

0 commit comments

Comments
 (0)