Skip to content

Commit

Permalink
bug #18924 [DoctrineBridge] Don't use object IDs in DoctrineChoiceLoa…
Browse files Browse the repository at this point in the history
…der when passing a value closure (webmozart)

This PR was merged into the 2.7 branch.

Discussion
----------

[DoctrineBridge] Don't use object IDs in DoctrineChoiceLoader when passing a value closure

| Q             | A
| ------------- | ---
| Branch?       | 2.7
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | -
| License       | MIT
| Doc PR        | -

This PR is porting an optimization done for `loadChoicesForValues()` in 64c80a6 to `loadValuesForChoices()`.

Commits
-------

f6e5298 [DoctrineBridge] Don't use object IDs in DoctrineChoiceLoader when passing a value closure
  • Loading branch information
fabpot committed Jun 22, 2016
2 parents eaca0bb + f6e5298 commit 80057b0
Show file tree
Hide file tree
Showing 3 changed files with 466 additions and 2 deletions.
Expand Up @@ -110,9 +110,10 @@ public function loadValuesForChoices(array $choices, $value = null)

// Optimize performance for single-field identifiers. We already
// know that the IDs are used as values
$optimize = null === $value || is_array($value) && $value[0] === $this->idReader;

// Attention: This optimization does not check choices for existence
if (!$this->choiceList && $this->idReader->isSingleId()) {
if ($optimize && !$this->choiceList && $this->idReader->isSingleId()) {
$values = array();

// Maintain order and indices of the given objects
Expand Down

0 comments on commit 80057b0

Please sign in to comment.