Merge branch '3.4' into 4.2

* 3.4:
  [Cache] Only delete one key at a time when on Predis + Cluster
  [Validator] Add missing translations for Swedish locale
  [Routing] removed a useless var
  [Routing] Fixed XML options resolution
This commit is contained in:
Nicolas Grekas 2019-03-11 14:02:11 +01:00
commit 8af31f845d
6 changed files with 53 additions and 3 deletions

View File

@ -385,7 +385,7 @@ trait RedisTrait
return true; return true;
} }
if ($this->redis instanceof \Predis\Client) { if ($this->redis instanceof \Predis\Client && $this->redis->getConnection() instanceof ClusterInterface) {
$this->pipeline(function () use ($ids) { $this->pipeline(function () use ($ids) {
foreach ($ids as $id) { foreach ($ids as $id) {
yield 'del' => [$id]; yield 'del' => [$id];

View File

@ -48,7 +48,7 @@ class PhpFileLoader extends FileLoader
if (\is_object($result) && \is_callable($result)) { if (\is_object($result) && \is_callable($result)) {
$collection = new RouteCollection(); $collection = new RouteCollection();
$result(new RoutingConfigurator($collection, $this, $path, $file), $this); $result(new RoutingConfigurator($collection, $this, $path, $file));
} else { } else {
$collection = $result; $collection = $result;
} }

View File

@ -268,6 +268,7 @@ class XmlFileLoader extends FileLoader
$prefixes = []; $prefixes = [];
$paths = []; $paths = [];
/** @var \DOMElement $n */
foreach ($node->getElementsByTagNameNS(self::NAMESPACE_URI, '*') as $n) { foreach ($node->getElementsByTagNameNS(self::NAMESPACE_URI, '*') as $n) {
if ($node !== $n->parentNode) { if ($node !== $n->parentNode) {
continue; continue;
@ -292,7 +293,7 @@ class XmlFileLoader extends FileLoader
$requirements[$n->getAttribute('key')] = trim($n->textContent); $requirements[$n->getAttribute('key')] = trim($n->textContent);
break; break;
case 'option': case 'option':
$options[$n->getAttribute('key')] = trim($n->textContent); $options[$n->getAttribute('key')] = XmlUtils::phpize(trim($n->textContent));
break; break;
case 'condition': case 'condition':
$condition = trim($n->textContent); $condition = trim($n->textContent);

View File

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8" ?>
<routes xmlns="http://symfony.com/schema/routing"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/routing
http://symfony.com/schema/routing/routing-1.0.xsd">
<route id="app_utf8" path="/utf8">
<option key="utf8">true</option>
</route>
<route id="app_no_utf8" path="/no-utf8">
<option key="utf8">false</option>
</route>
</routes>

View File

@ -83,6 +83,26 @@ class XmlFileLoaderTest extends TestCase
} }
} }
public function testUtf8Route()
{
$loader = new XmlFileLoader(new FileLocator([__DIR__.'/../Fixtures/localized']));
$routeCollection = $loader->load('utf8.xml');
$routes = $routeCollection->all();
$this->assertCount(2, $routes, 'Two routes are loaded');
$this->assertContainsOnly('Symfony\Component\Routing\Route', $routes);
$utf8Route = $routeCollection->get('app_utf8');
$this->assertSame('/utf8', $utf8Route->getPath());
$this->assertTrue($utf8Route->getOption('utf8'), 'Must be utf8');
$noUtf8Route = $routeCollection->get('app_no_utf8');
$this->assertSame('/no-utf8', $noUtf8Route->getPath());
$this->assertFalse($noUtf8Route->getOption('utf8'), 'Must not be utf8');
}
public function testLoadLocalized() public function testLoadLocalized()
{ {
$loader = new XmlFileLoader(new FileLocator([__DIR__.'/../Fixtures'])); $loader = new XmlFileLoader(new FileLocator([__DIR__.'/../Fixtures']));

View File

@ -318,6 +318,22 @@
<source>Error</source> <source>Error</source>
<target>Fel</target> <target>Fel</target>
</trans-unit> </trans-unit>
<trans-unit id="83">
<source>This is not a valid UUID.</source>
<target>Detta är inte ett giltigt UUID.</target>
</trans-unit>
<trans-unit id="84">
<source>This value should be a multiple of {{ compared_value }}.</source>
<target>Detta värde ska vara en multipel av {{ compared_value }}.</target>
</trans-unit>
<trans-unit id="85">
<source>This Business Identifier Code (BIC) is not associated with IBAN {{ iban }}.</source>
<target>Denna BIC-koden är inte associerad med IBAN {{ iban }}.</target>
</trans-unit>
<trans-unit id="86">
<source>This value should be valid JSON.</source>
<target>Detta värde ska vara giltig JSON.</target>
</trans-unit>
</body> </body>
</file> </file>
</xliff> </xliff>