Skip to content

[Form] Fixed regression causing invalid "WHERE id IN ()" statements #9001

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 12, 2013
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions src/Symfony/Bridge/Doctrine/Form/ChoiceList/EntityChoiceList.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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.

Expand Down