Skip to content

Commit

Permalink
bug #52606 [DoctrineBridge] Fix use "attribute" driver by default (vt…
Browse files Browse the repository at this point in the history
…sykun)

This PR was merged into the 7.0 branch.

Discussion
----------

[DoctrineBridge] Fix use "attribute" driver by default

| Q             | A
| ------------- | ---
| Branch?       | 7.0
| Bug fix?      | yes
| New feature?  | -
| Deprecations? | -
| Issues        | -
| License       | MIT

When I tested 7.0-RC1 version I noticed an error of detect doctrine driver type by default
```
In AbstractDoctrineExtension.php line 219:

  [InvalidArgumentException]
  Mapping definitions for Doctrine manager "default" require at least the "type", "dir" and "prefix" options.

Exception trace:
  at /var/www/packeton5/vendor/symfony/doctrine-bridge/DependencyInjection/AbstractDoctrineExtension.php:219
 Symfony\Bridge\Doctrine\DependencyInjection\AbstractDoctrineExtension->assertValidMappingConfiguration() at /var/www/packeton5/vendor/symfony/doctrine-bridge/DependencyInjection/AbstractDoctrineExtension.php:97
 Symfony\Bridge\Doctrine\DependencyInjection\AbstractDoctrineExtension->loadMappingInformation() at /var/www/packeton5/vendor/doctrine/doctrine-bundle/DependencyInjection/DoctrineExtension.php:837
 Doctrine\Bundle\DoctrineBundle\DependencyInjection\DoctrineExtension->loadOrmEntityManagerMappingInformation() at /var/www/packeton5/vendor/doctrine/doctrine-bundle/DependencyInjection/DoctrineExtension.php:657

```

my config
```yaml
doctrine:
    orm:
        mappings:
            Packeton:
                is_bundle: false
                dir: '%kernel.project_dir%/src/Entity'
                prefix: 'Packeton\Entity'
                alias: Packeton
```

Bug was introduced here https://github.com/symfony/symfony/pull/52142/files#diff-0f981a325d8c9eea80a258c36237861d1d00b0fb62fb04f2488bf2165776c94eR94

This conditions is never executed, because `$mappingConfig['type']` is false by default
```
$mappingConfig['type'] ??= 'attribute';
```
![Tooltip_016](https://github.com/symfony/symfony/assets/21358010/93fd8cd8-4432-47e4-89e1-348a63f5eb9a)

Commits
-------

44e9339 [DoctrineBridge] Fix use "attribute" driver by default
  • Loading branch information
nicolas-grekas committed Nov 17, 2023
2 parents dc1eccc + 44e9339 commit 2fe1c71
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@ protected function loadMappingInformation(array $objectManager, ContainerBuilder
if (!$mappingConfig) {
continue;
}
} else {
$mappingConfig['type'] ??= 'attribute';
} elseif (!$mappingConfig['type']) {
$mappingConfig['type'] = 'attribute';
}

$this->assertValidMappingConfiguration($mappingConfig, $objectManager['name']);
Expand Down

0 comments on commit 2fe1c71

Please sign in to comment.