merged branch bschussek/issue6190 (PR #6216)
This PR was merged into the 2.1 branch.
Commits
-------
ca5d9ac
[DoctrineBridge] Fixed caching in DoctrineType when "choices" or "preferred_choices" is passed
Discussion
----------
[DoctrineBridge] Fixed caching in DoctrineType when "choices" or "preferred_choices" is passed
Bug fix: yes
Feature addition: no
Backwards compatibility break: no
Symfony2 tests pass: yes
Fixes the following tickets: #6190
Todo: -
License of the code: MIT
Documentation PR: n/a
---------------------------------------------------------------------------
by craue at 2012-12-06T18:31:43Z
👍
---------------------------------------------------------------------------
by lstrojny at 2012-12-06T18:35:04Z
What about a test?
---------------------------------------------------------------------------
by bschussek at 2012-12-07T12:39:51Z
Removed CHANGELOG entries and added tests.
---------------------------------------------------------------------------
by craue at 2012-12-07T13:14:02Z
I'm not sure if @fabpot is objected to the changelog entry entirely or just the version number. What is the segfault about for PHP 5.4 in Travis?
This commit is contained in:
commit
992707ea6c
@ -77,16 +77,16 @@ abstract class DoctrineType extends AbstractType
|
|||||||
// A second parameter ($key) is passed, so we cannot use
|
// A second parameter ($key) is passed, so we cannot use
|
||||||
// spl_object_hash() directly (which strictly requires
|
// spl_object_hash() directly (which strictly requires
|
||||||
// one parameter)
|
// one parameter)
|
||||||
array_walk_recursive($choiceHashes, function ($value) {
|
array_walk_recursive($choiceHashes, function (&$value) {
|
||||||
return spl_object_hash($value);
|
$value = spl_object_hash($value);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
$preferredChoiceHashes = $options['preferred_choices'];
|
$preferredChoiceHashes = $options['preferred_choices'];
|
||||||
|
|
||||||
if (is_array($preferredChoiceHashes)) {
|
if (is_array($preferredChoiceHashes)) {
|
||||||
array_walk_recursive($preferredChoiceHashes, function ($value) {
|
array_walk_recursive($preferredChoiceHashes, function (&$value) {
|
||||||
return spl_object_hash($value);
|
$value = spl_object_hash($value);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -104,7 +104,7 @@ class EntityTypePerformanceTest extends FormPerformanceTestCase
|
|||||||
{
|
{
|
||||||
$this->setMaxRunningTime(1);
|
$this->setMaxRunningTime(1);
|
||||||
|
|
||||||
for ($i = 0; $i < 20; ++$i) {
|
for ($i = 0; $i < 40; ++$i) {
|
||||||
$form = $this->factory->create('entity', null, array(
|
$form = $this->factory->create('entity', null, array(
|
||||||
'class' => self::ENTITY_CLASS,
|
'class' => self::ENTITY_CLASS,
|
||||||
));
|
));
|
||||||
@ -114,11 +114,14 @@ class EntityTypePerformanceTest extends FormPerformanceTestCase
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @group benchmark
|
||||||
|
*/
|
||||||
public function testCollapsedEntityFieldWithQueryBuilder()
|
public function testCollapsedEntityFieldWithQueryBuilder()
|
||||||
{
|
{
|
||||||
$this->setMaxRunningTime(1);
|
$this->setMaxRunningTime(1);
|
||||||
|
|
||||||
for ($i = 0; $i < 20; ++$i) {
|
for ($i = 0; $i < 40; ++$i) {
|
||||||
$form = $this->factory->create('entity', null, array(
|
$form = $this->factory->create('entity', null, array(
|
||||||
'class' => self::ENTITY_CLASS,
|
'class' => self::ENTITY_CLASS,
|
||||||
'query_builder' => function (EntityRepository $repo) {
|
'query_builder' => function (EntityRepository $repo) {
|
||||||
@ -130,4 +133,42 @@ class EntityTypePerformanceTest extends FormPerformanceTestCase
|
|||||||
$form->createView();
|
$form->createView();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @group benchmark
|
||||||
|
*/
|
||||||
|
public function testCollapsedEntityFieldWithChoices()
|
||||||
|
{
|
||||||
|
$choices = $this->em->createQuery('SELECT c FROM ' . self::ENTITY_CLASS . ' c')->getResult();
|
||||||
|
$this->setMaxRunningTime(1);
|
||||||
|
|
||||||
|
for ($i = 0; $i < 40; ++$i) {
|
||||||
|
$form = $this->factory->create('entity', null, array(
|
||||||
|
'class' => self::ENTITY_CLASS,
|
||||||
|
'choices' => $choices,
|
||||||
|
));
|
||||||
|
|
||||||
|
// force loading of the choice list
|
||||||
|
$form->createView();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @group benchmark
|
||||||
|
*/
|
||||||
|
public function testCollapsedEntityFieldWithPreferredChoices()
|
||||||
|
{
|
||||||
|
$choices = $this->em->createQuery('SELECT c FROM ' . self::ENTITY_CLASS . ' c')->getResult();
|
||||||
|
$this->setMaxRunningTime(1);
|
||||||
|
|
||||||
|
for ($i = 0; $i < 40; ++$i) {
|
||||||
|
$form = $this->factory->create('entity', null, array(
|
||||||
|
'class' => self::ENTITY_CLASS,
|
||||||
|
'preferred_choices' => $choices,
|
||||||
|
));
|
||||||
|
|
||||||
|
// force loading of the choice list
|
||||||
|
$form->createView();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user