merged branch bschussek/issue8981-regression (PR #9001)
This PR was merged into the 2.2 branch.
Discussion
----------
[Form] Fixed regression causing invalid "WHERE id IN ()" statements
| Q | A
| ------------- | ---
| Bug fix? | yes
| New feature? | no
| BC breaks? | no
| Deprecations? | no
| Tests pass? | yes
| Fixed tickets | -
| License | MIT
| Doc PR | -
Commits
-------
867b81a
[Form] Fixed regression causing invalid "WHERE id IN ()" statements
This commit is contained in:
commit
ee05995bd5
|
@ -204,6 +204,16 @@ class EntityChoiceList extends ObjectChoiceList
|
|||
*/
|
||||
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 @@ class EntityChoiceList extends ObjectChoiceList
|
|||
*/
|
||||
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 @@ class EntityChoiceList extends ObjectChoiceList
|
|||
*/
|
||||
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 @@ class EntityChoiceList extends ObjectChoiceList
|
|||
*/
|
||||
public function getIndicesForValues(array $values)
|
||||
{
|
||||
// Performance optimization
|
||||
if (empty($values)) {
|
||||
return array();
|
||||
}
|
||||
|
||||
if (!$this->loaded) {
|
||||
// Optimize performance for single-field identifiers.
|
||||
|
||||
|
|
Reference in New Issue