Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge release 2.11.1 into 2.12.x #1730

Merged
merged 1 commit into from
Nov 15, 2023
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
10 changes: 9 additions & 1 deletion DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use Doctrine\ORM\EntityManager;
use Doctrine\ORM\EntityRepository;
use Doctrine\ORM\Mapping\ClassMetadataFactory;
use Doctrine\ORM\Mapping\Driver\AnnotationDriver;
use Doctrine\ORM\Proxy\ProxyFactory;
use InvalidArgumentException;
use ReflectionClass;
Expand Down Expand Up @@ -661,7 +662,14 @@ private function getOrmEntityManagersNode(): ArrayNodeDefinition
->arrayNode('schema_ignore_classes')
->prototype('scalar')->end()
->end()
->scalarNode('report_fields_where_declared')->defaultFalse()->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.')->end()
->booleanNode('report_fields_where_declared')
->defaultValue(! class_exists(AnnotationDriver::class))
->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.')
->validate()
->ifTrue(static fn (bool $v): bool => ! class_exists(AnnotationDriver::class) && ! $v)
->thenInvalid('The setting "report_fields_where_declared" cannot be disabled for ORM 3.')
->end()
->end()
->booleanNode('validate_xml_mapping')->defaultFalse()->info('Set to "true" to opt-in to the new mapping driver mode that was added in Doctrine ORM 2.14 and will be mandatory in ORM 3.0. See https://github.com/doctrine/orm/pull/6728.')->end()
->end()
->children()
Expand Down
21 changes: 19 additions & 2 deletions Tests/DependencyInjection/AbstractDoctrineExtensionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
use Doctrine\ORM\Configuration as OrmConfiguration;
use Doctrine\ORM\EntityManager;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\Mapping\Driver\AnnotationDriver;
use Doctrine\ORM\Mapping\Driver\SimplifiedXmlDriver;
use Doctrine\ORM\Proxy\ProxyFactory;
use Generator;
Expand All @@ -28,6 +29,7 @@
use Symfony\Bundle\DoctrineBundle\Tests\DependencyInjection\TestHydrator;
use Symfony\Component\Cache\Adapter\ArrayAdapter;
use Symfony\Component\Cache\Adapter\PhpArrayAdapter;
use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\Compiler\ResolveChildDefinitionsPass;
use Symfony\Component\DependencyInjection\ContainerBuilder;
Expand Down Expand Up @@ -568,7 +570,7 @@ public function testSingleEntityManagerMultipleMappingBundleDefinitions(): void
__DIR__ . DIRECTORY_SEPARATOR . 'Fixtures' . DIRECTORY_SEPARATOR . 'Bundles' . DIRECTORY_SEPARATOR . 'AttributesBundle' . DIRECTORY_SEPARATOR . 'Entity',
],
),
false,
! class_exists(AnnotationDriver::class),
]);

$ymlDef = $container->getDefinition('doctrine.orm.default_yml_metadata_driver');
Expand Down Expand Up @@ -627,7 +629,7 @@ public function testMultipleEntityManagersMappingBundleDefinitions(): void
[
__DIR__ . DIRECTORY_SEPARATOR . 'Fixtures' . DIRECTORY_SEPARATOR . 'Bundles' . DIRECTORY_SEPARATOR . 'AnnotationsBundle' . DIRECTORY_SEPARATOR . 'Entity',
],
false,
! class_exists(AnnotationDriver::class),
]);
}

Expand Down Expand Up @@ -972,6 +974,21 @@ public function testDisablingLazyGhostOnOrm3Throws(): void
$this->loadContainer('orm_no_lazy_ghost');
}

public function testDisablingReportFieldsWhereDeclaredOnOrm3Throws(): void
{
if (! interface_exists(EntityManagerInterface::class)) {
self::markTestSkipped('This test requires ORM');
}

if (class_exists(AnnotationDriver::class)) {
self::markTestSkipped('This test requires ORM 3.');
}

$this->expectException(InvalidConfigurationException::class);
$this->expectExceptionMessage('Invalid configuration for path "doctrine.orm.entity_managers.default.report_fields_where_declared": The setting "report_fields_where_declared" cannot be disabled for ORM 3.');
$this->loadContainer('orm_no_report_fields');
}

public function testResolveTargetEntity(): void
{
if (! interface_exists(EntityManagerInterface::class)) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0" ?>

<srv:container xmlns="http://symfony.com/schema/dic/doctrine"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:srv="http://symfony.com/schema/dic/services"
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd
http://symfony.com/schema/dic/doctrine http://symfony.com/schema/dic/doctrine/doctrine-1.0.xsd">

<config>
<dbal default-connection="default">
<connection name="default" dbname="db" />
</dbal>

<orm report-fields-where-declared="false" />
</config>
</srv:container>
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
doctrine:
dbal:
default_connection: default
connections:
default:
dbname: db

orm:
report_fields_where_declared: false