Skip to content

Commit 7d10d76

Browse files
authored
Merge pull request #1967 from greg0ire/3.0.x
Merge 2.17.x up into 3.0.x
2 parents d903708 + 2af10ea commit 7d10d76

File tree

9 files changed

+77
-8
lines changed

9 files changed

+77
-8
lines changed

UPGRADE-2.17.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
UPGRADE FROM 2.16 to 2.17
2+
=========================
3+
4+
Configuration
5+
-------------
6+
7+
### The `doctrine.orm.entity_managers.some_em.report_fields_where_declared` configuration option is deprecated
8+
9+
This option is a no-op when using `doctrine/orm` 3 and has been conditionally
10+
deprecated. You should stop using it as soon as you upgrade to Doctrine ORM 3.

src/DependencyInjection/Configuration.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace Doctrine\Bundle\DoctrineBundle\DependencyInjection;
44

55
use Doctrine\DBAL\Schema\LegacySchemaManagerFactory;
6+
use Doctrine\Deprecations\Deprecation;
67
use Doctrine\ORM\EntityManager;
78
use Doctrine\ORM\EntityRepository;
89
use Doctrine\ORM\Mapping\ClassMetadata;
@@ -670,6 +671,18 @@ private function getOrmEntityManagersNode(): ArrayNodeDefinition
670671
->prototype('scalar')->end()
671672
->end()
672673
->booleanNode('report_fields_where_declared')
674+
->beforeNormalization()
675+
->ifTrue(static fn ($v): bool => isset($v))
676+
->then(static function ($v) {
677+
Deprecation::trigger(
678+
'doctrine/doctrine-bundle',
679+
'https://github.com/doctrine/DoctrineBundle/pull/1962',
680+
'The "report_fields_where_declared" configuration option is deprecated and will be removed in DoctrineBundle 3.0. When using ORM 3, report_fields_where_declared will always be true.',
681+
);
682+
683+
return $v;
684+
})
685+
->end()
673686
->defaultValue(true)
674687
->info('Set to "true" to opt-in to the new mapping driver mode that was added in Doctrine ORM 2.16 and will be mandatory in ORM 3.0. See https://github.com/doctrine/orm/pull/10455.')
675688
->validate()

tests/DependencyInjection/AbstractDoctrineExtensionTestCase.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
use Doctrine\DBAL\Connections\PrimaryReadReplicaConnection;
1313
use Doctrine\DBAL\Platforms\PostgreSQLPlatform;
1414
use Doctrine\DBAL\Schema\LegacySchemaManagerFactory;
15+
use Doctrine\Deprecations\PHPUnit\VerifyDeprecations;
1516
use Doctrine\ORM\EntityManager;
1617
use Doctrine\ORM\EntityManagerInterface;
1718
use Doctrine\ORM\Mapping\ClassMetadata;
@@ -56,6 +57,8 @@
5657

5758
abstract class AbstractDoctrineExtensionTestCase extends TestCase
5859
{
60+
use VerifyDeprecations;
61+
5962
abstract protected function loadFromFile(ContainerBuilder $container, string $file): void;
6063

6164
public function testDbalLoadFromXmlMultipleConnections(): void
@@ -912,6 +915,7 @@ public function testDisablingLazyGhostOnOrm3Throws(): void
912915
$this->loadContainer('orm_no_lazy_ghost');
913916
}
914917

918+
/** @group legacy */
915919
public function testDisablingReportFieldsWhereDeclaredOnOrm3Throws(): void
916920
{
917921
if (! interface_exists(EntityManagerInterface::class)) {
@@ -923,6 +927,21 @@ public function testDisablingReportFieldsWhereDeclaredOnOrm3Throws(): void
923927
$this->loadContainer('orm_no_report_fields');
924928
}
925929

930+
/** @group legacy */
931+
public function testEnablingReportFieldsWhereDeclaredOnOrm3IsDeprecated(): void
932+
{
933+
if (! interface_exists(EntityManagerInterface::class)) {
934+
self::markTestSkipped('This test requires ORM');
935+
}
936+
937+
if (class_exists(AnnotationDriver::class)) {
938+
self::markTestSkipped('This test requires ORM 3.');
939+
}
940+
941+
$this->expectDeprecationWithIdentifier('https://github.com/doctrine/DoctrineBundle/pull/1962');
942+
$this->loadContainer('orm_report_fields');
943+
}
944+
926945
public function testResolveTargetEntity(): void
927946
{
928947
if (! interface_exists(EntityManagerInterface::class)) {

tests/DependencyInjection/Compiler/IdGeneratorPassTest.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use Doctrine\Bundle\DoctrineBundle\Tests\DependencyInjection\Fixtures\CustomIdGenerator;
88
use Doctrine\ORM\Configuration;
99
use Doctrine\ORM\EntityManagerInterface;
10+
use Doctrine\ORM\Mapping\Driver\AnnotationDriver;
1011
use Fixtures\Bundles\AttributesBundle\AttributesBundle;
1112
use Fixtures\Bundles\AttributesBundle\Entity\TestCustomIdGeneratorEntity as AttributeCustomIdGeneratorEntity;
1213
use PHPUnit\Framework\TestCase;
@@ -15,6 +16,7 @@
1516
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag;
1617

1718
use function assert;
19+
use function class_exists;
1820
use function interface_exists;
1921
use function method_exists;
2022
use function sys_get_temp_dir;
@@ -88,11 +90,10 @@ public function testRepositoryServiceWiring(): void
8890
],
8991
'orm' => [
9092
'mappings' => $mappings,
91-
'report_fields_where_declared' => true,
9293
'enable_lazy_ghost_objects' => true,
9394
/** @phpstan-ignore function.alreadyNarrowedType */
9495
'enable_native_lazy_objects' => PHP_VERSION_ID >= 80400 && method_exists(Configuration::class, 'enableNativeLazyObjects'),
95-
],
96+
] + (class_exists(AnnotationDriver::class) ? ['report_fields_where_declared' => true] : []),
9697
],
9798
], $container);
9899

tests/DependencyInjection/DoctrineExtensionTest.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -808,11 +808,10 @@ public function testAttributesBundleMappingDetection(): void
808808
'default_entity_manager' => 'default',
809809
'entity_managers' => [
810810
'default' => [
811-
'report_fields_where_declared' => true,
812811
'mappings' => [
813812
'AttributesBundle' => ['type' => 'attribute'],
814813
],
815-
],
814+
] + (class_exists(AnnotationDriver::class) ? ['report_fields_where_declared' => true] : []),
816815
],
817816
])
818817
->build();

tests/DependencyInjection/Fixtures/TestKernel.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,15 @@
44

55
use Doctrine\Bundle\DoctrineBundle\DoctrineBundle;
66
use Doctrine\ORM\Configuration;
7+
use Doctrine\ORM\Mapping\Driver\AnnotationDriver;
78
use Psr\Log\NullLogger;
89
use Symfony\Bundle\FrameworkBundle\FrameworkBundle;
910
use Symfony\Component\Config\Loader\LoaderInterface;
1011
use Symfony\Component\DependencyInjection\ContainerBuilder;
1112
use Symfony\Component\HttpKernel\Bundle\Bundle;
1213
use Symfony\Component\HttpKernel\Kernel;
1314

15+
use function class_exists;
1416
use function md5;
1517
use function method_exists;
1618
use function mt_rand;
@@ -51,7 +53,6 @@ public function registerContainerConfiguration(LoaderInterface $loader): void
5153
'schema_manager_factory' => 'doctrine.dbal.default_schema_manager_factory',
5254
],
5355
'orm' => [
54-
'report_fields_where_declared' => true,
5556
'auto_generate_proxy_classes' => true,
5657
'enable_lazy_ghost_objects' => true,
5758
/** @phpstan-ignore function.alreadyNarrowedType */
@@ -63,7 +64,7 @@ public function registerContainerConfiguration(LoaderInterface $loader): void
6364
'prefix' => 'Fixtures\Bundles\RepositoryServiceBundle\Entity',
6465
],
6566
],
66-
],
67+
] + (class_exists(AnnotationDriver::class) ? ['report_fields_where_declared' => true] : []),
6768
]);
6869

6970
// Register a NullLogger to avoid getting the stderr default logger of FrameworkBundle
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?xml version="1.0" ?>
2+
3+
<srv:container xmlns="http://symfony.com/schema/dic/doctrine"
4+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5+
xmlns:srv="http://symfony.com/schema/dic/services"
6+
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd
7+
http://symfony.com/schema/dic/doctrine http://symfony.com/schema/dic/doctrine/doctrine-1.0.xsd">
8+
9+
<config>
10+
<dbal default-connection="default">
11+
<connection name="default" dbname="db" />
12+
</dbal>
13+
14+
<orm report-fields-where-declared="true" />
15+
</config>
16+
</srv:container>
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
doctrine:
2+
dbal:
3+
default_connection: default
4+
connections:
5+
default:
6+
dbname: db
7+
8+
orm:
9+
report_fields_where_declared: true

tests/ServiceRepositoryTest.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use Doctrine\ORM\Configuration;
88
use Doctrine\ORM\EntityManagerInterface;
99
use Doctrine\ORM\EntityRepository;
10+
use Doctrine\ORM\Mapping\Driver\AnnotationDriver;
1011
use Doctrine\ORM\QueryBuilder;
1112
use Fixtures\Bundles\RepositoryServiceBundle\Entity\TestCustomClassRepoEntity;
1213
use Fixtures\Bundles\RepositoryServiceBundle\Entity\TestCustomServiceRepoEntity;
@@ -19,6 +20,7 @@
1920
use Symfony\Component\DependencyInjection\ContainerBuilder;
2021
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag;
2122

23+
use function class_exists;
2224
use function interface_exists;
2325
use function method_exists;
2426
use function sys_get_temp_dir;
@@ -81,7 +83,6 @@ public function testRepositoryServiceWiring(): void
8183
'schema_manager_factory' => 'doctrine.dbal.default_schema_manager_factory',
8284
],
8385
'orm' => [
84-
'report_fields_where_declared' => true,
8586
'enable_lazy_ghost_objects' => true,
8687
/** @phpstan-ignore function.alreadyNarrowedType */
8788
'enable_native_lazy_objects' => PHP_VERSION_ID >= 80400 && method_exists(Configuration::class, 'enableNativeLazyObjects'),
@@ -92,7 +93,7 @@ public function testRepositoryServiceWiring(): void
9293
'prefix' => 'Fixtures\Bundles\RepositoryServiceBundle\Entity',
9394
],
9495
],
95-
],
96+
] + (class_exists(AnnotationDriver::class) ? ['report_fields_where_declared' => true] : []),
9697
],
9798
], $container);
9899

0 commit comments

Comments
 (0)