Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit a66e9ff

Browse files
committed
Merge branch '2.7' into 2.8
* 2.7: [Translation][fallback] add missing resources in parent catalogues. removed a deprecation notice [Form] Fix show float values as choices values in ChoiceType [HttpFoundation][Session] memcached connection should not be closed
2 parents 3dcbdfd + 8668aec commit a66e9ff

File tree

7 files changed

+37
-14
lines changed

7 files changed

+37
-14
lines changed

src/Symfony/Bridge/Twig/NodeVisitor/TranslationDefaultDomainNodeVisitor.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ protected function doEnterNode(\Twig_Node $node, \Twig_Environment $env)
4949

5050
return $node;
5151
} else {
52-
$var = $env->getParser()->getVarName();
52+
$var = $this->getVarName();
5353
$name = new \Twig_Node_Expression_AssignName($var, $node->getTemplateLine());
5454
$this->scope->set('domain', new \Twig_Node_Expression_Name($var, $node->getTemplateLine()));
5555

@@ -123,4 +123,9 @@ private function isNamedArguments($arguments)
123123

124124
return false;
125125
}
126+
127+
private function getVarName()
128+
{
129+
return sprintf('__internal_%s', hash('sha256', uniqid(mt_rand(), true), false));
130+
}
126131
}

src/Symfony/Component/Form/ChoiceList/ArrayChoiceList.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,11 @@ private function castableToString(array $choices, array &$cache = array())
236236
continue;
237237
} elseif (!is_scalar($choice)) {
238238
return false;
239-
} elseif (isset($cache[$choice])) {
239+
}
240+
241+
$choice = false === $choice ? '0' : (string) $choice;
242+
243+
if (isset($cache[$choice])) {
240244
return false;
241245
}
242246

src/Symfony/Component/Form/Tests/ChoiceList/ArrayChoiceListTest.php

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,12 @@ protected function createChoiceList()
3434

3535
protected function getChoices()
3636
{
37-
return array(0, 1, '1', 'a', false, true, $this->object, null);
37+
return array(0, 1, 1.5, '1', 'a', false, true, $this->object, null);
3838
}
3939

4040
protected function getValues()
4141
{
42-
return array('0', '1', '2', '3', '4', '5', '6', '7');
42+
return array('0', '1', '2', '3', '4', '5', '6', '7', '8');
4343
}
4444

4545
/**
@@ -162,4 +162,13 @@ public function testGetChoicesForValuesWithContainingEmptyStringAndBooleans()
162162
$this->assertSame(array(0 => true), $choiceList->getChoicesForValues(array('1')));
163163
$this->assertSame(array(0 => false), $choiceList->getChoicesForValues(array('0')));
164164
}
165+
166+
public function testGetChoicesForValuesWithContainingEmptyStringAndFloats()
167+
{
168+
$choiceList = new ArrayChoiceList(array('Empty String' => '', '1/3' => 0.3, '1/2' => 0.5));
169+
170+
$this->assertSame(array(0 => ''), $choiceList->getChoicesForValues(array('')));
171+
$this->assertSame(array(0 => 0.3), $choiceList->getChoicesForValues(array('0.3')));
172+
$this->assertSame(array(0 => 0.5), $choiceList->getChoicesForValues(array('0.5')));
173+
}
165174
}

src/Symfony/Component/HttpFoundation/Session/Storage/Handler/MemcacheSessionHandler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public function open($savePath, $sessionName)
7171
*/
7272
public function close()
7373
{
74-
return $this->memcache->close();
74+
return true;
7575
}
7676

7777
/**

src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MemcacheSessionHandlerTest.php

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,6 @@ public function testOpenSession()
5656

5757
public function testCloseSession()
5858
{
59-
$this->memcache
60-
->expects($this->once())
61-
->method('close')
62-
->will($this->returnValue(true))
63-
;
64-
6559
$this->assertTrue($this->storage->close());
6660
}
6761

src/Symfony/Component/Translation/MessageCatalogue.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,10 @@ public function addFallbackCatalogue(MessageCatalogueInterface $catalogue)
178178
if ($c->getLocale() === $catalogue->getLocale()) {
179179
throw new \LogicException(sprintf('Circular reference detected when adding a fallback catalogue for locale "%s".', $catalogue->getLocale()));
180180
}
181+
182+
foreach ($catalogue->getResources() as $resource) {
183+
$c->addResource($resource);
184+
}
181185
} while ($c = $c->parent);
182186

183187
$catalogue->parent = $this;

src/Symfony/Component/Translation/Tests/MessageCatalogueTest.php

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,18 +110,25 @@ public function testAddFallbackCatalogue()
110110
$r1 = $this->getMock('Symfony\Component\Config\Resource\ResourceInterface');
111111
$r1->expects($this->any())->method('__toString')->will($this->returnValue('r1'));
112112

113-
$catalogue = new MessageCatalogue('en_US', array('domain1' => array('foo' => 'foo'), 'domain2' => array('bar' => 'bar')));
113+
$r2 = $this->getMock('Symfony\Component\Config\Resource\ResourceInterface');
114+
$r2->expects($this->any())->method('__toString')->will($this->returnValue('r2'));
115+
116+
$catalogue = new MessageCatalogue('fr_FR', array('domain1' => array('foo' => 'foo'), 'domain2' => array('bar' => 'bar')));
114117
$catalogue->addResource($r);
115118

116-
$catalogue1 = new MessageCatalogue('en', array('domain1' => array('foo' => 'bar', 'foo1' => 'foo1')));
119+
$catalogue1 = new MessageCatalogue('fr', array('domain1' => array('foo' => 'bar', 'foo1' => 'foo1')));
117120
$catalogue1->addResource($r1);
118121

122+
$catalogue2 = new MessageCatalogue('en');
123+
$catalogue2->addResource($r2);
124+
119125
$catalogue->addFallbackCatalogue($catalogue1);
126+
$catalogue1->addFallbackCatalogue($catalogue2);
120127

121128
$this->assertEquals('foo', $catalogue->get('foo', 'domain1'));
122129
$this->assertEquals('foo1', $catalogue->get('foo1', 'domain1'));
123130

124-
$this->assertEquals(array($r, $r1), $catalogue->getResources());
131+
$this->assertEquals(array($r, $r1, $r2), $catalogue->getResources());
125132
}
126133

127134
/**

0 commit comments

Comments
 (0)