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
This commit is contained in:
commit
a66e9ff77e
@ -49,7 +49,7 @@ class TranslationDefaultDomainNodeVisitor extends \Twig_BaseNodeVisitor
|
||||
|
||||
return $node;
|
||||
} else {
|
||||
$var = $env->getParser()->getVarName();
|
||||
$var = $this->getVarName();
|
||||
$name = new \Twig_Node_Expression_AssignName($var, $node->getTemplateLine());
|
||||
$this->scope->set('domain', new \Twig_Node_Expression_Name($var, $node->getTemplateLine()));
|
||||
|
||||
@ -123,4 +123,9 @@ class TranslationDefaultDomainNodeVisitor extends \Twig_BaseNodeVisitor
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private function getVarName()
|
||||
{
|
||||
return sprintf('__internal_%s', hash('sha256', uniqid(mt_rand(), true), false));
|
||||
}
|
||||
}
|
||||
|
@ -236,7 +236,11 @@ class ArrayChoiceList implements ChoiceListInterface
|
||||
continue;
|
||||
} elseif (!is_scalar($choice)) {
|
||||
return false;
|
||||
} elseif (isset($cache[$choice])) {
|
||||
}
|
||||
|
||||
$choice = false === $choice ? '0' : (string) $choice;
|
||||
|
||||
if (isset($cache[$choice])) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -34,12 +34,12 @@ class ArrayChoiceListTest extends AbstractChoiceListTest
|
||||
|
||||
protected function getChoices()
|
||||
{
|
||||
return array(0, 1, '1', 'a', false, true, $this->object, null);
|
||||
return array(0, 1, 1.5, '1', 'a', false, true, $this->object, null);
|
||||
}
|
||||
|
||||
protected function getValues()
|
||||
{
|
||||
return array('0', '1', '2', '3', '4', '5', '6', '7');
|
||||
return array('0', '1', '2', '3', '4', '5', '6', '7', '8');
|
||||
}
|
||||
|
||||
/**
|
||||
@ -162,4 +162,13 @@ class ArrayChoiceListTest extends AbstractChoiceListTest
|
||||
$this->assertSame(array(0 => true), $choiceList->getChoicesForValues(array('1')));
|
||||
$this->assertSame(array(0 => false), $choiceList->getChoicesForValues(array('0')));
|
||||
}
|
||||
|
||||
public function testGetChoicesForValuesWithContainingEmptyStringAndFloats()
|
||||
{
|
||||
$choiceList = new ArrayChoiceList(array('Empty String' => '', '1/3' => 0.3, '1/2' => 0.5));
|
||||
|
||||
$this->assertSame(array(0 => ''), $choiceList->getChoicesForValues(array('')));
|
||||
$this->assertSame(array(0 => 0.3), $choiceList->getChoicesForValues(array('0.3')));
|
||||
$this->assertSame(array(0 => 0.5), $choiceList->getChoicesForValues(array('0.5')));
|
||||
}
|
||||
}
|
||||
|
@ -71,7 +71,7 @@ class MemcacheSessionHandler implements \SessionHandlerInterface
|
||||
*/
|
||||
public function close()
|
||||
{
|
||||
return $this->memcache->close();
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -56,12 +56,6 @@ class MemcacheSessionHandlerTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
public function testCloseSession()
|
||||
{
|
||||
$this->memcache
|
||||
->expects($this->once())
|
||||
->method('close')
|
||||
->will($this->returnValue(true))
|
||||
;
|
||||
|
||||
$this->assertTrue($this->storage->close());
|
||||
}
|
||||
|
||||
|
@ -178,6 +178,10 @@ class MessageCatalogue implements MessageCatalogueInterface, MetadataAwareInterf
|
||||
if ($c->getLocale() === $catalogue->getLocale()) {
|
||||
throw new \LogicException(sprintf('Circular reference detected when adding a fallback catalogue for locale "%s".', $catalogue->getLocale()));
|
||||
}
|
||||
|
||||
foreach ($catalogue->getResources() as $resource) {
|
||||
$c->addResource($resource);
|
||||
}
|
||||
} while ($c = $c->parent);
|
||||
|
||||
$catalogue->parent = $this;
|
||||
|
@ -110,18 +110,25 @@ class MessageCatalogueTest extends \PHPUnit_Framework_TestCase
|
||||
$r1 = $this->getMock('Symfony\Component\Config\Resource\ResourceInterface');
|
||||
$r1->expects($this->any())->method('__toString')->will($this->returnValue('r1'));
|
||||
|
||||
$catalogue = new MessageCatalogue('en_US', array('domain1' => array('foo' => 'foo'), 'domain2' => array('bar' => 'bar')));
|
||||
$r2 = $this->getMock('Symfony\Component\Config\Resource\ResourceInterface');
|
||||
$r2->expects($this->any())->method('__toString')->will($this->returnValue('r2'));
|
||||
|
||||
$catalogue = new MessageCatalogue('fr_FR', array('domain1' => array('foo' => 'foo'), 'domain2' => array('bar' => 'bar')));
|
||||
$catalogue->addResource($r);
|
||||
|
||||
$catalogue1 = new MessageCatalogue('en', array('domain1' => array('foo' => 'bar', 'foo1' => 'foo1')));
|
||||
$catalogue1 = new MessageCatalogue('fr', array('domain1' => array('foo' => 'bar', 'foo1' => 'foo1')));
|
||||
$catalogue1->addResource($r1);
|
||||
|
||||
$catalogue2 = new MessageCatalogue('en');
|
||||
$catalogue2->addResource($r2);
|
||||
|
||||
$catalogue->addFallbackCatalogue($catalogue1);
|
||||
$catalogue1->addFallbackCatalogue($catalogue2);
|
||||
|
||||
$this->assertEquals('foo', $catalogue->get('foo', 'domain1'));
|
||||
$this->assertEquals('foo1', $catalogue->get('foo1', 'domain1'));
|
||||
|
||||
$this->assertEquals(array($r, $r1), $catalogue->getResources());
|
||||
$this->assertEquals(array($r, $r1, $r2), $catalogue->getResources());
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user