From 53a6ff88f77e47c81e3bcee061fc1cf95cfc8dcb Mon Sep 17 00:00:00 2001 From: Jules Pietri Date: Sun, 10 Mar 2019 15:36:46 +0100 Subject: [PATCH 1/5] [Routing] Fixed XML options resolution --- .../Routing/Loader/XmlFileLoader.php | 3 ++- .../Routing/Tests/Fixtures/localized/utf8.xml | 13 ++++++++++++ .../Tests/Loader/XmlFileLoaderTest.php | 20 +++++++++++++++++++ 3 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 src/Symfony/Component/Routing/Tests/Fixtures/localized/utf8.xml diff --git a/src/Symfony/Component/Routing/Loader/XmlFileLoader.php b/src/Symfony/Component/Routing/Loader/XmlFileLoader.php index e56add97a3..444a08a776 100644 --- a/src/Symfony/Component/Routing/Loader/XmlFileLoader.php +++ b/src/Symfony/Component/Routing/Loader/XmlFileLoader.php @@ -208,6 +208,7 @@ class XmlFileLoader extends FileLoader $options = []; $condition = null; + /** @var \DOMElement $n */ foreach ($node->getElementsByTagNameNS(self::NAMESPACE_URI, '*') as $n) { if ($node !== $n->parentNode) { continue; @@ -226,7 +227,7 @@ class XmlFileLoader extends FileLoader $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); diff --git a/src/Symfony/Component/Routing/Tests/Fixtures/localized/utf8.xml b/src/Symfony/Component/Routing/Tests/Fixtures/localized/utf8.xml new file mode 100644 index 0000000000..95aff20cfe --- /dev/null +++ b/src/Symfony/Component/Routing/Tests/Fixtures/localized/utf8.xml @@ -0,0 +1,13 @@ + + + + + + + + + + diff --git a/src/Symfony/Component/Routing/Tests/Loader/XmlFileLoaderTest.php b/src/Symfony/Component/Routing/Tests/Loader/XmlFileLoaderTest.php index 66588e7e90..9a061b295a 100644 --- a/src/Symfony/Component/Routing/Tests/Loader/XmlFileLoaderTest.php +++ b/src/Symfony/Component/Routing/Tests/Loader/XmlFileLoaderTest.php @@ -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'); + } + /** * @expectedException \InvalidArgumentException * @dataProvider getPathsToInvalidFiles From 10c1313d418823c1a88d097d51ceaf4f75e44f19 Mon Sep 17 00:00:00 2001 From: Jules Pietri Date: Sun, 10 Mar 2019 19:46:42 +0100 Subject: [PATCH 2/5] [Routing] removed a useless var --- src/Symfony/Component/Routing/Loader/PhpFileLoader.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Component/Routing/Loader/PhpFileLoader.php b/src/Symfony/Component/Routing/Loader/PhpFileLoader.php index 9e009387dd..d81e7e82e7 100644 --- a/src/Symfony/Component/Routing/Loader/PhpFileLoader.php +++ b/src/Symfony/Component/Routing/Loader/PhpFileLoader.php @@ -48,7 +48,7 @@ class PhpFileLoader extends FileLoader if ($result instanceof \Closure) { $collection = new RouteCollection(); - $result(new RoutingConfigurator($collection, $this, $path, $file), $this); + $result(new RoutingConfigurator($collection, $this, $path, $file)); } else { $collection = $result; } From aa6e5851f16db970fb6521df90e5723475087814 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Sun, 10 Mar 2019 21:07:02 +0100 Subject: [PATCH 3/5] [Process] fix using argument $php of new PhpProcess() --- src/Symfony/Component/Process/PhpProcess.php | 9 ++++----- .../Component/Process/Tests/PhpProcessTest.php | 15 +++++++++++++++ 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/src/Symfony/Component/Process/PhpProcess.php b/src/Symfony/Component/Process/PhpProcess.php index 6ebf7377ce..126d9b754f 100644 --- a/src/Symfony/Component/Process/PhpProcess.php +++ b/src/Symfony/Component/Process/PhpProcess.php @@ -33,11 +33,10 @@ class PhpProcess extends Process */ public function __construct(string $script, string $cwd = null, array $env = null, int $timeout = 60, array $php = null) { - $executableFinder = new PhpExecutableFinder(); - if (false === $php = $php ?? $executableFinder->find(false)) { - $php = null; - } else { - $php = array_merge([$php], $executableFinder->findArguments()); + if (null === $php) { + $executableFinder = new PhpExecutableFinder(); + $php = $executableFinder->find(false); + $php = false === $php ? null : array_merge([$php], $executableFinder->findArguments()); } if ('phpdbg' === \PHP_SAPI) { $file = tempnam(sys_get_temp_dir(), 'dbg'); diff --git a/src/Symfony/Component/Process/Tests/PhpProcessTest.php b/src/Symfony/Component/Process/Tests/PhpProcessTest.php index b0f0a57ace..0355c85be6 100644 --- a/src/Symfony/Component/Process/Tests/PhpProcessTest.php +++ b/src/Symfony/Component/Process/Tests/PhpProcessTest.php @@ -12,6 +12,7 @@ namespace Symfony\Component\Process\Tests; use PHPUnit\Framework\TestCase; +use Symfony\Component\Process\PhpExecutableFinder; use Symfony\Component\Process\PhpProcess; class PhpProcessTest extends TestCase @@ -45,4 +46,18 @@ PHP $this->assertSame(PHP_VERSION.\PHP_SAPI, $process->getOutput()); } + + public function testPassingPhpExplicitly() + { + $finder = new PhpExecutableFinder(); + $php = array_merge([$finder->find(false)], $finder->findArguments()); + + $expected = 'hello world!'; + $script = <<run(); + $this->assertEquals($expected, $process->getOutput()); + } } From 7e9f63da43bc0ad5a659ce74a838ce0aa7b1a435 Mon Sep 17 00:00:00 2001 From: Tobias Genberg Date: Mon, 11 Mar 2019 00:40:03 +0100 Subject: [PATCH 4/5] [Validator] Add missing translations for Swedish locale --- .../Resources/translations/validators.sv.xlf | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/Symfony/Component/Validator/Resources/translations/validators.sv.xlf b/src/Symfony/Component/Validator/Resources/translations/validators.sv.xlf index fa043ea23a..e8b214958f 100644 --- a/src/Symfony/Component/Validator/Resources/translations/validators.sv.xlf +++ b/src/Symfony/Component/Validator/Resources/translations/validators.sv.xlf @@ -318,6 +318,22 @@ Error Fel + + This is not a valid UUID. + Detta är inte ett giltigt UUID. + + + This value should be a multiple of {{ compared_value }}. + Detta värde ska vara en multipel av {{ compared_value }}. + + + This Business Identifier Code (BIC) is not associated with IBAN {{ iban }}. + Denna BIC-koden är inte associerad med IBAN {{ iban }}. + + + This value should be valid JSON. + Detta värde ska vara giltig JSON. + From f5ece20a8397c97156ab998e7fd351d8833ad59d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andre=CC=81=20R?= Date: Mon, 11 Mar 2019 11:49:54 +0100 Subject: [PATCH 5/5] [Cache] Only delete one key at a time when on Predis + Cluster --- src/Symfony/Component/Cache/Traits/RedisTrait.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Component/Cache/Traits/RedisTrait.php b/src/Symfony/Component/Cache/Traits/RedisTrait.php index 7cbd304a0c..7f5d191692 100644 --- a/src/Symfony/Component/Cache/Traits/RedisTrait.php +++ b/src/Symfony/Component/Cache/Traits/RedisTrait.php @@ -272,7 +272,17 @@ trait RedisTrait */ protected function doDelete(array $ids) { - if ($ids) { + if (!$ids) { + return true; + } + + if ($this->redis instanceof \Predis\Client && $this->redis->getConnection() instanceof ClusterInterface) { + $this->pipeline(function () use ($ids) { + foreach ($ids as $id) { + yield 'del' => [$id]; + } + })->rewind(); + } else { $this->redis->del($ids); }