From 867b81af5a8c699324526f9c2c8c286c88b61532 Mon Sep 17 00:00:00 2001 From: Bernhard Schussek Date: Thu, 12 Sep 2013 10:13:57 +0200 Subject: [PATCH] [Form] Fixed regression causing invalid "WHERE id IN ()" statements --- .../Form/ChoiceList/EntityChoiceList.php | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/Symfony/Bridge/Doctrine/Form/ChoiceList/EntityChoiceList.php b/src/Symfony/Bridge/Doctrine/Form/ChoiceList/EntityChoiceList.php index c3510515c5f5e..189a90fa94fbc 100644 --- a/src/Symfony/Bridge/Doctrine/Form/ChoiceList/EntityChoiceList.php +++ b/src/Symfony/Bridge/Doctrine/Form/ChoiceList/EntityChoiceList.php @@ -204,6 +204,16 @@ public function getRemainingViews() */ public function getChoicesForValues(array $values) { + // Performance optimization + // Also prevents the generation of "WHERE id IN ()" queries through the + // entity loader. At least with MySQL and on the development machine + // this was tested on, no exception was thrown for such invalid + // statements, consequently no test fails when this code is removed. + // https://github.com/symfony/symfony/pull/8981#issuecomment-24230557 + if (empty($values)) { + return array(); + } + if (!$this->loaded) { // Optimize performance in case we have an entity loader and // a single-field identifier @@ -247,6 +257,11 @@ public function getChoicesForValues(array $values) */ public function getValuesForChoices(array $entities) { + // Performance optimization + if (empty($entities)) { + return array(); + } + if (!$this->loaded) { // Optimize performance for single-field identifiers. We already // know that the IDs are used as values @@ -282,6 +297,11 @@ public function getValuesForChoices(array $entities) */ public function getIndicesForChoices(array $entities) { + // Performance optimization + if (empty($entities)) { + return array(); + } + if (!$this->loaded) { // Optimize performance for single-field identifiers. We already // know that the IDs are used as indices @@ -317,6 +337,11 @@ public function getIndicesForChoices(array $entities) */ public function getIndicesForValues(array $values) { + // Performance optimization + if (empty($values)) { + return array(); + } + if (!$this->loaded) { // Optimize performance for single-field identifiers. pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy