minor #34610 [DoctrineBridge] Removed legacy checks in DoctrineChoiceLoader (HeahDude)

This PR was merged into the 5.0 branch.

Discussion
----------

[DoctrineBridge] Removed legacy checks in DoctrineChoiceLoader

| Q             | A
| ------------- | ---
| Branch?       | 5.0
| Bug fix?      | no
| New feature? | no <!-- please update src/**/CHANGELOG.md files -->
| Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files -->
| Tickets       | ~
| License       | MIT
| Doc PR        | ~
<!--
Replace this notice by a short README for your feature/bugfix. This will help people
understand your PR and can be used as a start for the documentation.

Additionally (see https://symfony.com/roadmap):
 - Always add tests and ensure they pass.
 - Never break backward compatibility (see https://symfony.com/bc).
 - Bug fixes must be submitted against the lowest maintained branch where they apply
   (lowest branches are regularly merged to upper ones so they get the fixes too.)
 - Features and deprecations must be submitted against branch master.
-->

Commits
-------

20d2cca7f0 [DoctrineBridge] Removed legacy checks in DoctrineChoiceLoader
This commit is contained in:
Nicolas Grekas 2019-11-27 22:23:27 +01:00
commit a2cb37e1e2

View File

@ -87,7 +87,7 @@ class DoctrineChoiceLoader implements ChoiceLoaderInterface
$optimize = $this->idReader && (null === $value || \is_array($value) && $value[0] === $this->idReader);
// Attention: This optimization does not check choices for existence
if ($optimize && !$this->choiceList && $this->idReader->isSingleId()) {
if ($optimize && !$this->choiceList) {
$values = [];
// Maintain order and indices of the given objects
@ -123,7 +123,7 @@ class DoctrineChoiceLoader implements ChoiceLoaderInterface
// a single-field identifier
$optimize = $this->idReader && (null === $value || \is_array($value) && $this->idReader === $value[0]);
if ($optimize && !$this->choiceList && $this->objectLoader && $this->idReader->isSingleId()) {
if ($optimize && !$this->choiceList && $this->objectLoader) {
$unorderedObjects = $this->objectLoader->getEntitiesByIds($this->idReader->getIdField(), $values);
$objectsById = [];
$objects = [];