8000 merged branch bschussek/issue6190 (PR #6216) · symfony/symfony@992707e · GitHub
[go: up one dir, main page]

Skip to content

Commit 992707e

Browse files
committed
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 :+1: --------------------------------------------------------------------------- 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?
2 parents 864cc85 + ca5d9ac commit 992707e

File tree

2 files changed

+47
-6
lines changed

2 files changed

+47
-6
lines changed

src/Symfony/Bridge/Doctrine/Form/Type/DoctrineType.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,16 +77,16 @@ public function setDefaultOptions(OptionsResolverInterface $resolver)
7777
// A second parameter ($key) is passed, so we cannot use
7878
// spl_object_hash() directly (which strictly requires
7979
// one parameter)
80-
array_walk_recursive($choiceHashes, function ($value) {
81-
return spl_object_hash($value);
80+
array_walk_recursive($choiceHashes, function (&$value) {
81+
$value = spl_object_hash($value);
8282
});
8383
}
8484

8585
$preferredChoiceHashes = $options['preferred_choices'];
8686

8787
if (is_array($preferredChoiceHashes)) {
88-
array_walk_recursive($preferredChoiceHashes, function ($value) {
89-
return spl_object_hash($value);
88+
array_walk_recursive($preferredChoiceHashes, function (&$value) {
89+
$value = spl_object_hash($value);
9090
});
9191
}
9292

src/Symfony/Bridge/Doctrine/Tests/Form/Type/EntityTypePerformanceTest.php

Lines changed: 43 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ public function testCollapsedEntityField()
104104
{
105105
$this->setMaxRunningTime(1);
106106

107-
for ($i = 0; $i < 20; ++$i) {
107+
for ($i = 0; $i < 40; ++$i) {
108108
$form = $this->factory->create('entity', null, array(
109109
'class' => self::ENTITY_CLASS,
110110
));
@@ -114,11 +114,14 @@ public function testCollapsedEntityField()
114114
}
115115
}
116116

117+
/**
118+
* @group benchmark
119+
*/
117120
public function testCollapsedEntityFieldWithQueryBuilder()
118121
{
119122
$this->setMaxRunningTime(1);
120123

121-
for ($i = 0; $i < 20; ++$i) {
124+
for ($i = 0; $i < 40; ++$i) {
122125
$form = $this->factory->create('entity', null, array(
123126
'class' => self::ENTITY_CLASS,
124127
'query_builder' => function (EntityRepository $repo) {
@@ -130,4 +133,42 @@ public function testCollapsedEntityFieldWithQueryBuilder()
130133
$form->createView();
131134
}
132135
}
136+
137+
/**
138+
* @group benchmark
139+
*/
140+
public function testCollapsedEntityFieldWithChoices()
141+
{
142+
$choices = $this->em->createQuery('SELECT c FROM ' . self::ENTITY_CLASS . ' c')->getResult();
143+
$this->setMaxRunningTime(1);
144+
145+
for ($i = 0; $i < 40; ++$i) {
146+
$form = $this->factory->create('entity', null, array(
147+
'class' => self::ENTITY_CLASS,
148+
'choices' => $choices,
149+
));
150+
151+
// force loading of the choice list
152+
$form->createView();
153+
}
154+
}
155+
156+
/**
157+
* @group benchmark
158+
*/
159+
public function testCollapsedEntityFieldWithPreferredChoices()
160+
{
161+
$choices = $this->em->createQuery('SELECT c FROM ' . self::ENTITY_CLASS . ' c')->getResult();
162+
$this->setMaxRunningTime(1);
163+
164+
for ($i = 0; $i < 40; ++$i) {
165+
$form = $this->factory->create('entity', null, array(
166+
'class' => self::ENTITY_CLASS,
167+
'preferred_choices' => $choices,
168+
));
169+
170+
// force loading of the choice list
171+
$form->createView();
172+
}
173+
}
133174
}

0 commit comments

Comments
 (0)
0