From e665da0c9a1338608bfee9875535e6317d308843 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Thu, 28 Jun 2018 11:33:10 +0200 Subject: [PATCH 1/6] [Lock] fix locale dependent test case --- src/Symfony/Component/Lock/Tests/Store/SemaphoreStoreTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Component/Lock/Tests/Store/SemaphoreStoreTest.php b/src/Symfony/Component/Lock/Tests/Store/SemaphoreStoreTest.php index 23b90360be..7057505072 100644 --- a/src/Symfony/Component/Lock/Tests/Store/SemaphoreStoreTest.php +++ b/src/Symfony/Component/Lock/Tests/Store/SemaphoreStoreTest.php @@ -50,7 +50,7 @@ class SemaphoreStoreTest extends AbstractStoreTest private function getOpenedSemaphores() { - $lines = explode(PHP_EOL, trim(`ipcs -su`)); + $lines = explode(PHP_EOL, trim(`LC_ALL=C ipcs -su`)); if ('------ Semaphore Status --------' !== $lines[0]) { throw new \Exception('Failed to extract list of opend semaphores. Expect a Semaphore status, got '.implode(PHP_EOL, $lines)); } From fe7fc4408516421a31e8ca9461e43d2cbc726e6d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Dunglas?= Date: Thu, 28 Jun 2018 13:49:38 +0200 Subject: [PATCH 2/6] [Validator] Fix the namespace of RegexTest --- src/Symfony/Component/Validator/Tests/Constraints/RegexTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Component/Validator/Tests/Constraints/RegexTest.php b/src/Symfony/Component/Validator/Tests/Constraints/RegexTest.php index 3291c77356..26ef1b2736 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/RegexTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/RegexTest.php @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -namespace Constraints; +namespace Symfony\Component\Validator\Tests\Constraints; use PHPUnit\Framework\TestCase; use Symfony\Component\Validator\Constraints\Regex; From 2258ce4357fbba00deff7420d7d7760a7e2353f9 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Fri, 29 Jun 2018 13:03:55 +0200 Subject: [PATCH 3/6] [Form] relax fixtures for forward compat --- .../Fixtures/Descriptor/default_option_with_normalizer.txt | 2 +- .../Descriptor/overridden_option_with_default_closures.txt | 4 ++-- .../Descriptor/required_option_with_allowed_values.txt | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Symfony/Component/Form/Tests/Fixtures/Descriptor/default_option_with_normalizer.txt b/src/Symfony/Component/Form/Tests/Fixtures/Descriptor/default_option_with_normalizer.txt index c622057cdb..87d656a3fa 100644 --- a/src/Symfony/Component/Form/Tests/Fixtures/Descriptor/default_option_with_normalizer.txt +++ b/src/Symfony/Component/Form/Tests/Fixtures/Descriptor/default_option_with_normalizer.txt @@ -15,7 +15,7 @@ Symfony\Component\Form\Extension\Core\Type\ChoiceType (choice_translation_domain ---------------- --------------------%s Allowed values - %s ---------------- --------------------%s - Normalizer Closure { %s + Normalizer Closure%s{ %s parameters: 2 %s file: "%s%eExtension%eCore%eType%eChoiceType.php" line: "%s to %s" %s diff --git a/src/Symfony/Component/Form/Tests/Fixtures/Descriptor/overridden_option_with_default_closures.txt b/src/Symfony/Component/Form/Tests/Fixtures/Descriptor/overridden_option_with_default_closures.txt index 231d1319bb..967d177c7e 100644 --- a/src/Symfony/Component/Form/Tests/Fixtures/Descriptor/overridden_option_with_default_closures.txt +++ b/src/Symfony/Component/Form/Tests/Fixtures/Descriptor/overridden_option_with_default_closures.txt @@ -8,12 +8,12 @@ Symfony\Component\Form\Tests\Console\Descriptor\FooType (empty_data) Default Value: null %s %s Closure(s): [ %s - Closure { %s + Closure%s{ %s parameters: 1 %s file: "%s%eExtension%eCore%eType%eFormType.php" line: "%s to %s" %s }, %s - Closure { %s + Closure%s{ %s parameters: 2 %s file: "%s%eTests%eConsole%eDescriptor%eAbstractDescriptorTest.php" line: "%s to %s" %s diff --git a/src/Symfony/Component/Form/Tests/Fixtures/Descriptor/required_option_with_allowed_values.txt b/src/Symfony/Component/Form/Tests/Fixtures/Descriptor/required_option_with_allowed_values.txt index da3e6c82d8..0d2e7f44d9 100644 --- a/src/Symfony/Component/Form/Tests/Fixtures/Descriptor/required_option_with_allowed_values.txt +++ b/src/Symfony/Component/Form/Tests/Fixtures/Descriptor/required_option_with_allowed_values.txt @@ -16,7 +16,7 @@ Symfony\Component\Form\Tests\Console\Descriptor\FooType (foo) "baz" %s ] %s ---------------- --------------------%s - Normalizer Closure { %s + Normalizer Closure%s{ %s parameters: 2 %s file: "%s%eTests%eConsole%eDescriptor%eAbstractDescriptorTest.php" line: "%s to %s" %s From 6e5c15d8aa0babf1da519f56f4bc8770a36e28ee Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Mon, 25 Jun 2018 11:39:34 +0200 Subject: [PATCH 4/6] bug #27701 [SecurityBundle] Dont throw if "security.http_utils" is not found (nicolas-grekas) This PR was merged into the 3.4 branch. Discussion ---------- [SecurityBundle] Dont throw if "security.http_utils" is not found | Q | A | ------------- | --- | Branch? | 3.4 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #27445 | License | MIT | Doc PR | - The comment + test were misleading, the actual important thing is wiring `AddSessionDomainConstraintPass` before removing passes, which is already the case already. Commits ------- db88330448 [SecurityBundle] Dont throw if "security.http_utils" is not found --- .../Compiler/AddSessionDomainConstraintPass.php | 3 +-- .../Compiler/AddSessionDomainConstraintPassTest.php | 13 ------------- 2 files changed, 1 insertion(+), 15 deletions(-) diff --git a/src/Symfony/Bundle/SecurityBundle/DependencyInjection/Compiler/AddSessionDomainConstraintPass.php b/src/Symfony/Bundle/SecurityBundle/DependencyInjection/Compiler/AddSessionDomainConstraintPass.php index ba523382b6..3dd18944de 100644 --- a/src/Symfony/Bundle/SecurityBundle/DependencyInjection/Compiler/AddSessionDomainConstraintPass.php +++ b/src/Symfony/Bundle/SecurityBundle/DependencyInjection/Compiler/AddSessionDomainConstraintPass.php @@ -26,7 +26,7 @@ class AddSessionDomainConstraintPass implements CompilerPassInterface */ public function process(ContainerBuilder $container) { - if (!$container->hasParameter('session.storage.options')) { + if (!$container->hasParameter('session.storage.options') || !$container->has('security.http_utils')) { return; } @@ -34,7 +34,6 @@ class AddSessionDomainConstraintPass implements CompilerPassInterface $domainRegexp = empty($sessionOptions['cookie_domain']) ? '%s' : sprintf('(?:%%s|(?:.+\.)?%s)', preg_quote(trim($sessionOptions['cookie_domain'], '.'))); $domainRegexp = (empty($sessionOptions['cookie_secure']) ? 'https?://' : 'https://').$domainRegexp; - // if the service doesn't exist, an exception must be thrown - ignoring would put security at risk $container->findDefinition('security.http_utils')->addArgument(sprintf('{^%s$}i', $domainRegexp)); } } diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Compiler/AddSessionDomainConstraintPassTest.php b/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Compiler/AddSessionDomainConstraintPassTest.php index e12f3a64f3..7d49ad3dd4 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Compiler/AddSessionDomainConstraintPassTest.php +++ b/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Compiler/AddSessionDomainConstraintPassTest.php @@ -96,19 +96,6 @@ class AddSessionDomainConstraintPassTest extends TestCase $this->assertTrue($utils->createRedirectResponse($request, 'http://pirate.com/foo')->isRedirect('http://pirate.com/foo')); } - /** - * @expectedException \Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException - * @expectedExceptionMessage You have requested a non-existent service "security.http_utils". - */ - public function testNoHttpUtils() - { - $container = new ContainerBuilder(); - $container->setParameter('session.storage.options', array()); - - $pass = new AddSessionDomainConstraintPass(); - $pass->process($container); - } - private function createContainer($sessionStorageOptions) { $container = new ContainerBuilder(); From 3ca0c86afe12c1b85e0fea9b95fa2c052c361d38 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Fri, 29 Jun 2018 16:05:32 +0200 Subject: [PATCH 5/6] [ProxyManagerBridge] Fix support of private services (bis) --- .../Bridge/ProxyManager/LazyProxy/PhpDumper/ProxyDumper.php | 3 ++- .../ProxyManager/Tests/LazyProxy/PhpDumper/ProxyDumperTest.php | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Bridge/ProxyManager/LazyProxy/PhpDumper/ProxyDumper.php b/src/Symfony/Bridge/ProxyManager/LazyProxy/PhpDumper/ProxyDumper.php index 4a54cc7658..1e47f4424b 100644 --- a/src/Symfony/Bridge/ProxyManager/LazyProxy/PhpDumper/ProxyDumper.php +++ b/src/Symfony/Bridge/ProxyManager/LazyProxy/PhpDumper/ProxyDumper.php @@ -15,6 +15,7 @@ use ProxyManager\Generator\ClassGenerator; use ProxyManager\GeneratorStrategy\BaseGeneratorStrategy; use ProxyManager\Version; use Symfony\Component\DependencyInjection\Container; +use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Definition; use Symfony\Component\DependencyInjection\LazyProxy\PhpDumper\DumperInterface; @@ -57,7 +58,7 @@ class ProxyDumper implements DumperInterface $instantiation = 'return'; if ($definition->isShared()) { - $instantiation .= sprintf(' $this->%s[\'%s\'] =', $definition->isPublic() && !$definition->isPrivate() ? 'services' : 'privates', $id); + $instantiation .= sprintf(' $this->%s[\'%s\'] =', \method_exists(ContainerBuilder::class, 'addClassResource') || ($definition->isPublic() && !$definition->isPrivate()) ? 'services' : 'privates', $id); } if (null === $factoryCode) { diff --git a/src/Symfony/Bridge/ProxyManager/Tests/LazyProxy/PhpDumper/ProxyDumperTest.php b/src/Symfony/Bridge/ProxyManager/Tests/LazyProxy/PhpDumper/ProxyDumperTest.php index 357b26844c..8bdc631466 100644 --- a/src/Symfony/Bridge/ProxyManager/Tests/LazyProxy/PhpDumper/ProxyDumperTest.php +++ b/src/Symfony/Bridge/ProxyManager/Tests/LazyProxy/PhpDumper/ProxyDumperTest.php @@ -13,6 +13,7 @@ namespace Symfony\Bridge\ProxyManager\Tests\LazyProxy\PhpDumper; use PHPUnit\Framework\TestCase; use Symfony\Bridge\ProxyManager\LazyProxy\PhpDumper\ProxyDumper; +use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Definition; /** @@ -101,7 +102,7 @@ class ProxyDumperTest extends TestCase array( (new Definition(__CLASS__)) ->setPublic(false), - 'privates', + \method_exists(ContainerBuilder::class, 'addClassResource') ? 'services' : 'privates', ), array( (new Definition(__CLASS__)) From 9135e18deddbebacd67bd5d3945a566f0af7a01a Mon Sep 17 00:00:00 2001 From: Sir Kane Date: Thu, 28 Jun 2018 18:39:54 +0000 Subject: [PATCH 6/6] [HttpFoundation] update phpdoc of FlashBagInterface::add() --- .../Session/Flash/FlashBagInterface.php | 2 +- .../Tests/Session/Flash/FlashBagTest.php | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Component/HttpFoundation/Session/Flash/FlashBagInterface.php b/src/Symfony/Component/HttpFoundation/Session/Flash/FlashBagInterface.php index 80e97f17cd..f53c9dae6c 100644 --- a/src/Symfony/Component/HttpFoundation/Session/Flash/FlashBagInterface.php +++ b/src/Symfony/Component/HttpFoundation/Session/Flash/FlashBagInterface.php @@ -24,7 +24,7 @@ interface FlashBagInterface extends SessionBagInterface * Adds a flash message for type. * * @param string $type - * @param string $message + * @param mixed $message */ public function add($type, $message); diff --git a/src/Symfony/Component/HttpFoundation/Tests/Session/Flash/FlashBagTest.php b/src/Symfony/Component/HttpFoundation/Tests/Session/Flash/FlashBagTest.php index b44429d898..3ceb124771 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/Session/Flash/FlashBagTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/Session/Flash/FlashBagTest.php @@ -74,6 +74,18 @@ class FlashBagTest extends TestCase $this->assertEquals(array('A previous flash message'), $this->bag->peek('notice')); } + public function testAdd() + { + $tab = array('bar' => 'baz'); + $this->bag->add('string_message', 'lorem'); + $this->bag->add('object_message', new \stdClass()); + $this->bag->add('array_message', $tab); + + $this->assertEquals(array('lorem'), $this->bag->get('string_message')); + $this->assertEquals(array(new \stdClass()), $this->bag->get('object_message')); + $this->assertEquals(array($tab), $this->bag->get('array_message')); + } + public function testGet() { $this->assertEquals(array(), $this->bag->get('non_existing'));