Skip to content
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
5 changes: 5 additions & 0 deletions UPGRADE-2.17.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ Configuration
This option is a no-op when using `doctrine/orm` 3 and has been conditionally
deprecated. You should stop using it as soon as you upgrade to Doctrine ORM 3.

### The `doctrine.dbal.connections.some_connection.disable_type_comments` configuration option is deprecated

This option is a no-op when using `doctrine/dbal` 4 and has been conditionally
deprecated. You should stop using it as soon as you upgrade to Doctrine DBAL 4.

ConnectionFactory::createConnection() signature change
------------------------------------------------------

Expand Down
18 changes: 17 additions & 1 deletion src/DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

namespace Doctrine\Bundle\DoctrineBundle\DependencyInjection;

use Doctrine\DBAL\Connection;
use Doctrine\Deprecations\Deprecation;
use Doctrine\ORM\EntityManager;
use Doctrine\ORM\EntityRepository;
use Doctrine\ORM\Mapping\ClassMetadata;
Expand All @@ -29,6 +31,7 @@
use function is_array;
use function is_string;
use function key;
use function method_exists;
use function reset;
use function sprintf;
use function strtoupper;
Expand Down Expand Up @@ -185,7 +188,20 @@ private function getDbalConnectionsNode(): ArrayNodeDefinition
->defaultValue(true)
->info('Enables collecting schema errors when profiling is enabled')
->end()
->booleanNode('disable_type_comments')->end()
->booleanNode('disable_type_comments')
->beforeNormalization()
->ifTrue(static fn ($v): bool => isset($v) && ! method_exists(Connection::class, 'getEventManager'))
->then(static function ($v) {
Deprecation::trigger(
'doctrine/doctrine-bundle',
'https://github.com/doctrine/DoctrineBundle/pull/2048',
'The "disable_type_comments" configuration key is deprecated when using DBAL 4 and will be removed in DoctrineBundle 3.0.',
);

return $v;
})
->end()
->end()
->scalarNode('server_version')->end()
->integerNode('idle_connection_ttl')->defaultValue(600)->end()
->scalarNode('driver_class')->end()
Expand Down
26 changes: 26 additions & 0 deletions tests/DependencyInjection/AbstractDoctrineExtensionTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@
use Doctrine\Bundle\DoctrineBundle\DependencyInjection\DoctrineExtension;
use Doctrine\Bundle\DoctrineBundle\Tests\DependencyInjection\Fixtures\InvokableEntityListener;
use Doctrine\DBAL\Configuration;
use Doctrine\DBAL\Connection;
use Doctrine\DBAL\Connections\PrimaryReadReplicaConnection;
use Doctrine\DBAL\Platforms\PostgreSQLPlatform;
use Doctrine\Deprecations\PHPUnit\VerifyDeprecations;
use Doctrine\ORM\EntityManager;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\Mapping\ClassMetadata;
Expand Down Expand Up @@ -41,6 +43,7 @@
use function end;
use function interface_exists;
use function is_dir;
use function method_exists;
use function sprintf;
use function sys_get_temp_dir;
use function uniqid;
Expand All @@ -49,6 +52,8 @@

abstract class AbstractDoctrineExtensionTestCase extends TestCase
{
use VerifyDeprecations;

abstract protected function loadFromFile(ContainerBuilder $container, string $file): void;

public function testDbalLoadFromXmlMultipleConnections(): void
Expand Down Expand Up @@ -795,6 +800,27 @@ public function testAddFilter(): void
$this->assertCount(2, $entityManager->getFilters()->getEnabledFilters());
}

#[IgnoreDeprecations]
public function testSettingDisableTypeCommentsWithDbal4IsDeprecated(): void
{
if (method_exists(Connection::class, 'getEventManager')) {
self::markTestSkipped('This test requires DBAL 4.');
}

$this->expectDeprecationWithIdentifier('https://github.com/doctrine/DoctrineBundle/pull/2048');
$this->loadContainer('dbal_disable_type_comments');
}

public function testSettingDisableTypeCommentsWithDbal3IsFine(): void
{
if (! method_exists(Connection::class, 'getEventManager')) {
self::markTestSkipped('This test requires DBAL 3.');
}

$this->expectNoDeprecationWithIdentifier('https://github.com/doctrine/DoctrineBundle/pull/2048');
$this->loadContainer('dbal_disable_type_comments');
}

public function testResolveTargetEntity(): void
{
if (! interface_exists(EntityManagerInterface::class)) {
Expand Down