Skip to content

Commit

Permalink
Optimize EntityType by only loading choices for values in the same wa…
Browse files Browse the repository at this point in the history
…y that EntityLoader customization does (if you provide a query_builder).
  • Loading branch information
guilhermeblanco authored and fabpot committed Feb 21, 2015
1 parent 7b9bc80 commit a108445
Showing 1 changed file with 4 additions and 2 deletions.
Expand Up @@ -218,8 +218,10 @@ public function getChoicesForValues(array $values)
if (!$this->loaded) {
// Optimize performance in case we have an entity loader and
// a single-field identifier
if ($this->idAsValue && $this->entityLoader) {
$unorderedEntities = $this->entityLoader->getEntitiesByIds($this->idField, $values);
if ($this->idAsValue) {
$unorderedEntities = $this->entityLoader
? $this->entityLoader->getEntitiesByIds($this->idField, $values)
: $this->em->getRepository($this->class)->findBy(array($this->idField => $values));
$entitiesByValue = array();
$entities = array();

Expand Down

5 comments on commit a108445

@coudenysj
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was this tested on MongoDB? I filed issue #14025, because this introduces a bug.

@arendjantetteroo
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've got the same problem as i'm not including an entityLoader. I just use "field", null in my Form.

@coudenysj
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@arendjantetteroo Please have a look at #13961. Will be fixed in 2.7.

@arendjantetteroo
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@coudenysj I'm on 2.3.25. Broken in 2.3.26. So this needs to be fixed on the 2.3 branch as well. #14054

@mrohnstock
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Already reported #13961 and fixed, also for 2.3.

Please sign in to comment.