Skip to content

Commit

Permalink
Merge branch '3.4' into 4.2
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
nicolas-grekas committed Mar 11, 2019
2 parents 00fe6e6 + 21d0197 commit 8af31f8
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/Symfony/Component/Cache/Traits/RedisTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ protected function doDelete(array $ids)
return true;
}

if ($this->redis instanceof \Predis\Client) {
if ($this->redis instanceof \Predis\Client && $this->redis->getConnection() instanceof ClusterInterface) {
$this->pipeline(function () use ($ids) {
foreach ($ids as $id) {
yield 'del' => [$id];
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/Routing/Loader/PhpFileLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public function load($file, $type = null)

if (\is_object($result) && \is_callable($result)) {
$collection = new RouteCollection();
$result(new RoutingConfigurator($collection, $this, $path, $file), $this);
$result(new RoutingConfigurator($collection, $this, $path, $file));
} else {
$collection = $result;
}
Expand Down
3 changes: 2 additions & 1 deletion src/Symfony/Component/Routing/Loader/XmlFileLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,7 @@ private function parseConfigs(\DOMElement $node, $path)
$prefixes = [];
$paths = [];

/** @var \DOMElement $n */
foreach ($node->getElementsByTagNameNS(self::NAMESPACE_URI, '*') as $n) {
if ($node !== $n->parentNode) {
continue;
Expand All @@ -292,7 +293,7 @@ private function parseConfigs(\DOMElement $node, $path)
$requirements[$n->getAttribute('key')] = trim($n->textContent);
break;
case 'option':
$options[$n->getAttribute('key')] = trim($n->textContent);
$options[$n->getAttribute('key')] = XmlUtils::phpize(trim($n->textContent));
break;
case 'condition':
$condition = trim($n->textContent);
Expand Down
13 changes: 13 additions & 0 deletions src/Symfony/Component/Routing/Tests/Fixtures/localized/utf8.xml
Original file line number Diff line number Diff line change
@@ -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>
20 changes: 20 additions & 0 deletions src/Symfony/Component/Routing/Tests/Loader/XmlFileLoaderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,26 @@ public function testLoadWithImport()
}
}

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()
{
$loader = new XmlFileLoader(new FileLocator([__DIR__.'/../Fixtures']));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,22 @@
<source>Error</source>
<target>Fel</target>
</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>
</file>
</xliff>

0 comments on commit 8af31f8

Please sign in to comment.