From aebe8ae1632b363752808f80c3e72a76326769ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Pineau?= Date: Tue, 7 Apr 2020 11:39:41 +0200 Subject: [PATCH 01/10] [Workflow] Use a strict comparison when retrieving raw markin in MarkingStore --- .../MarkingStore/SingleStateMarkingStore.php | 2 +- .../MarkingStore/SingleStateMarkingStoreTest.php | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Component/Workflow/MarkingStore/SingleStateMarkingStore.php b/src/Symfony/Component/Workflow/MarkingStore/SingleStateMarkingStore.php index daccc65b41..cd102f4ce6 100644 --- a/src/Symfony/Component/Workflow/MarkingStore/SingleStateMarkingStore.php +++ b/src/Symfony/Component/Workflow/MarkingStore/SingleStateMarkingStore.php @@ -44,7 +44,7 @@ class SingleStateMarkingStore implements MarkingStoreInterface { $placeName = $this->propertyAccessor->getValue($subject, $this->property); - if (!$placeName) { + if (null === $placeName) { return new Marking(); } diff --git a/src/Symfony/Component/Workflow/Tests/MarkingStore/SingleStateMarkingStoreTest.php b/src/Symfony/Component/Workflow/Tests/MarkingStore/SingleStateMarkingStoreTest.php index 2e00714d27..0db37986cf 100644 --- a/src/Symfony/Component/Workflow/Tests/MarkingStore/SingleStateMarkingStoreTest.php +++ b/src/Symfony/Component/Workflow/Tests/MarkingStore/SingleStateMarkingStoreTest.php @@ -30,4 +30,17 @@ class SingleStateMarkingStoreTest extends TestCase $this->assertEquals($marking, $marking2); } + + public function testAlmostEmptyPlaceName() + { + $subject = new \stdClass(); + $subject->myMarks = 0; + + $markingStore = new SingleStateMarkingStore('myMarks'); + + $marking = $markingStore->getMarking($subject); + + $this->assertInstanceOf(Marking::class, $marking); + $this->assertCount(1, $marking->getPlaces()); + } } From a00a2f111532a5edc4726f2d540514d9007dc7aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Pineau?= Date: Tue, 7 Apr 2020 11:51:42 +0200 Subject: [PATCH 02/10] [Workflow] Use a strict comparison when retrieving raw marking in MarkingStore --- .../Workflow/MarkingStore/MethodMarkingStore.php | 2 +- .../Tests/MarkingStore/MethodMarkingStoreTest.php | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Component/Workflow/MarkingStore/MethodMarkingStore.php b/src/Symfony/Component/Workflow/MarkingStore/MethodMarkingStore.php index 8c219f502b..feb012913c 100644 --- a/src/Symfony/Component/Workflow/MarkingStore/MethodMarkingStore.php +++ b/src/Symfony/Component/Workflow/MarkingStore/MethodMarkingStore.php @@ -56,7 +56,7 @@ final class MethodMarkingStore implements MarkingStoreInterface $marking = $subject->{$method}(); - if (!$marking) { + if (null === $marking) { return new Marking(); } diff --git a/src/Symfony/Component/Workflow/Tests/MarkingStore/MethodMarkingStoreTest.php b/src/Symfony/Component/Workflow/Tests/MarkingStore/MethodMarkingStoreTest.php index 7393faa825..155f285a4a 100644 --- a/src/Symfony/Component/Workflow/Tests/MarkingStore/MethodMarkingStoreTest.php +++ b/src/Symfony/Component/Workflow/Tests/MarkingStore/MethodMarkingStoreTest.php @@ -53,6 +53,18 @@ class MethodMarkingStoreTest extends TestCase $this->assertEquals($marking, $marking2); } + public function testGetSetMarkingWithSingleStateAndAlmostEmptyPlaceName() + { + $subject = new Subject(0); + + $markingStore = new MethodMarkingStore(true); + + $marking = $markingStore->getMarking($subject); + + $this->assertInstanceOf(Marking::class, $marking); + $this->assertCount(1, $marking->getPlaces()); + } + public function testGetMarkingWithValueObject() { $subject = new Subject($this->createValueObject('first_place')); From a07578dba3004f0923fc91b03563163c771e0708 Mon Sep 17 00:00:00 2001 From: Antonio Pauletich Date: Tue, 7 Apr 2020 13:57:54 +0200 Subject: [PATCH 03/10] [HttpClient] Fix scoped client without query option configuration --- .../DependencyInjection/Configuration.php | 2 +- .../http_client_scoped_without_query_option.php | 11 +++++++++++ .../http_client_scoped_without_query_option.xml | 16 ++++++++++++++++ .../http_client_scoped_without_query_option.yml | 5 +++++ .../FrameworkExtensionTest.php | 8 ++++++++ 5 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/http_client_scoped_without_query_option.php create mode 100644 src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/http_client_scoped_without_query_option.xml create mode 100644 src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/http_client_scoped_without_query_option.yml diff --git a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php index 105695c963..13c63ff998 100644 --- a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php +++ b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php @@ -1482,7 +1482,7 @@ class Configuration implements ConfigurationInterface ->thenInvalid('Either "scope" or "base_uri" should be defined.') ->end() ->validate() - ->ifTrue(function ($v) { return isset($v['query']) && !isset($v['base_uri']); }) + ->ifTrue(function ($v) { return !empty($v['query']) && !isset($v['base_uri']); }) ->thenInvalid('"query" applies to "base_uri" but no base URI is defined.') ->end() ->children() diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/http_client_scoped_without_query_option.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/http_client_scoped_without_query_option.php new file mode 100644 index 0000000000..0d3dc88472 --- /dev/null +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/http_client_scoped_without_query_option.php @@ -0,0 +1,11 @@ +loadFromExtension('framework', [ + 'http_client' => [ + 'scoped_clients' => [ + 'foo' => [ + 'scope' => '.*', + ], + ], + ], +]); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/http_client_scoped_without_query_option.xml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/http_client_scoped_without_query_option.xml new file mode 100644 index 0000000000..43043aeda2 --- /dev/null +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/http_client_scoped_without_query_option.xml @@ -0,0 +1,16 @@ + + + + + + + + + diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/http_client_scoped_without_query_option.yml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/http_client_scoped_without_query_option.yml new file mode 100644 index 0000000000..ecfc9d41fd --- /dev/null +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/http_client_scoped_without_query_option.yml @@ -0,0 +1,5 @@ +framework: + http_client: + scoped_clients: + foo: + scope: '.*' diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php index edcdb7aae4..9a8fc0776f 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php @@ -1547,6 +1547,14 @@ abstract class FrameworkExtensionTest extends TestCase $this->assertSame(ScopingHttpClient::class, $container->getDefinition('foo')->getClass()); } + public function testScopedHttpClientWithoutQueryOption() + { + $container = $this->createContainerFromFile('http_client_scoped_without_query_option'); + + $this->assertTrue($container->hasDefinition('foo'), 'should have the "foo" service.'); + $this->assertSame(ScopingHttpClient::class, $container->getDefinition('foo')->getClass()); + } + public function testHttpClientOverrideDefaultOptions() { $container = $this->createContainerFromFile('http_client_override_default_options'); From b98abde65a65b1ba4dbab6ec187bb48ebd0a94cb Mon Sep 17 00:00:00 2001 From: Michel Bardelmeijer Date: Tue, 7 Apr 2020 21:12:26 +0200 Subject: [PATCH 04/10] Supress error from fread when reading a unix pipe --- src/Symfony/Component/Process/Pipes/UnixPipes.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Component/Process/Pipes/UnixPipes.php b/src/Symfony/Component/Process/Pipes/UnixPipes.php index 603d726b47..70fdd29574 100644 --- a/src/Symfony/Component/Process/Pipes/UnixPipes.php +++ b/src/Symfony/Component/Process/Pipes/UnixPipes.php @@ -118,7 +118,7 @@ class UnixPipes extends AbstractPipes $read[$type = array_search($pipe, $this->pipes, true)] = ''; do { - $data = fread($pipe, self::CHUNK_SIZE); + $data = @fread($pipe, self::CHUNK_SIZE); $read[$type] .= $data; } while (isset($data[0]) && ($close || isset($data[self::CHUNK_SIZE - 1]))); From bf17165fb1293aa3e10aacacb569423d86cdbd42 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Wed, 8 Apr 2020 16:17:20 +0200 Subject: [PATCH 05/10] [DI] fix detecting short service syntax in yaml --- .../DependencyInjection/Loader/YamlFileLoader.php | 2 +- .../Tests/Fixtures/yaml/services_short_syntax.yml | 6 ++++++ .../Tests/Loader/YamlFileLoaderTest.php | 11 +++++++++++ 3 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services_short_syntax.yml diff --git a/src/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php b/src/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php index a31959e456..986ccf0b81 100644 --- a/src/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php +++ b/src/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php @@ -299,7 +299,7 @@ class YamlFileLoader extends FileLoader private function isUsingShortSyntax(array $service): bool { foreach ($service as $key => $value) { - if (\is_string($key) && ('' === $key || '$' !== $key[0])) { + if (\is_string($key) && ('' === $key || ('$' !== $key[0] && false === strpos($key, '\\')))) { return false; } } diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services_short_syntax.yml b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services_short_syntax.yml new file mode 100644 index 0000000000..16ddb6bdf2 --- /dev/null +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services_short_syntax.yml @@ -0,0 +1,6 @@ +services: + foo_bar: [1, 2] + + bar_foo: + $a: 'a' + App\Foo: 'foo' diff --git a/src/Symfony/Component/DependencyInjection/Tests/Loader/YamlFileLoaderTest.php b/src/Symfony/Component/DependencyInjection/Tests/Loader/YamlFileLoaderTest.php index f40fc22cc3..eb6d01a197 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Loader/YamlFileLoaderTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Loader/YamlFileLoaderTest.php @@ -205,6 +205,17 @@ class YamlFileLoaderTest extends TestCase $this->assertEquals(['decorated', 'decorated.pif-pouf', 5, ContainerInterface::IGNORE_ON_INVALID_REFERENCE], $services['decorator_service_with_name_and_priority_and_on_invalid']->getDecoratedService()); } + public function testLoadShortSyntax() + { + $container = new ContainerBuilder(); + $loader = new YamlFileLoader($container, new FileLocator(self::$fixturesPath.'/yaml')); + $loader->load('services_short_syntax.yml'); + $services = $container->getDefinitions(); + + $this->assertSame([1, 2], $services['foo_bar']->getArguments()); + $this->assertSame(['$a' => 'a', 'App\Foo' => 'foo'], $services['bar_foo']->getArguments()); + } + public function testDeprecatedAliases() { $container = new ContainerBuilder(); From a6a4442cd98ef980d9979dc9f6b7ee6478439787 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Wed, 8 Apr 2020 22:51:14 +0200 Subject: [PATCH 06/10] [DI] add missing property declarations in InlineServiceConfigurator --- .../Loader/Configurator/AliasConfigurator.php | 1 + .../Loader/Configurator/InlineServiceConfigurator.php | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/src/Symfony/Component/DependencyInjection/Loader/Configurator/AliasConfigurator.php b/src/Symfony/Component/DependencyInjection/Loader/Configurator/AliasConfigurator.php index cb00f58c04..8ac635758b 100644 --- a/src/Symfony/Component/DependencyInjection/Loader/Configurator/AliasConfigurator.php +++ b/src/Symfony/Component/DependencyInjection/Loader/Configurator/AliasConfigurator.php @@ -20,6 +20,7 @@ class AliasConfigurator extends AbstractServiceConfigurator { const FACTORY = 'alias'; + use Traits\DeprecateTrait; use Traits\PublicTrait; public function __construct(ServicesConfigurator $parent, Alias $alias) diff --git a/src/Symfony/Component/DependencyInjection/Loader/Configurator/InlineServiceConfigurator.php b/src/Symfony/Component/DependencyInjection/Loader/Configurator/InlineServiceConfigurator.php index 362b374e55..ea5db9778b 100644 --- a/src/Symfony/Component/DependencyInjection/Loader/Configurator/InlineServiceConfigurator.php +++ b/src/Symfony/Component/DependencyInjection/Loader/Configurator/InlineServiceConfigurator.php @@ -29,6 +29,10 @@ class InlineServiceConfigurator extends AbstractConfigurator use Traits\ParentTrait; use Traits\TagTrait; + private $id = '[inline]'; + private $allowParent = true; + private $path = null; + public function __construct(Definition $definition) { $this->definition = $definition; From c9bf0c8683fd72a56d5b990692cf5e1d6987cf67 Mon Sep 17 00:00:00 2001 From: Ryan Weaver Date: Thu, 9 Apr 2020 10:29:41 -0400 Subject: [PATCH 07/10] Allowing empty secrets to be set --- .../FrameworkBundle/Command/SecretsSetCommand.php | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/SecretsSetCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/SecretsSetCommand.php index 5cca8d7011..91e0031299 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Command/SecretsSetCommand.php +++ b/src/Symfony/Bundle/FrameworkBundle/Command/SecretsSetCommand.php @@ -96,6 +96,11 @@ EOF $value = strtr(substr(base64_encode(random_bytes($random)), 0, $random), '+/', '-_'); } elseif (!$file = $input->getArgument('file')) { $value = $io->askHidden('Please type the secret value'); + + if (null === $value) { + $io->warning('No value provided: using empty string'); + $value = ''; + } } elseif ('-' === $file) { $value = file_get_contents('php://stdin'); } elseif (is_file($file) && is_readable($file)) { @@ -106,12 +111,6 @@ EOF throw new \InvalidArgumentException(sprintf('File is not readable: "%s".', $file)); } - if (null === $value) { - $io->warning('No value provided, aborting.'); - - return 1; - } - if ($vault->generateKeys()) { $io->success($vault->getLastMessage()); From 015d8d7e869b015e08080396d75ec9d177df6bdc Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Fri, 10 Apr 2020 22:02:31 +0200 Subject: [PATCH 08/10] =?UTF-8?q?[DI]=20=C2=B5fix?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Component/DependencyInjection/Loader/YamlFileLoader.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php b/src/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php index 5a011c04dd..ca52ff36c0 100644 --- a/src/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php +++ b/src/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php @@ -355,7 +355,7 @@ class YamlFileLoader extends FileLoader if (isset($service['alias'])) { $this->container->setAlias($id, $alias = new Alias($service['alias'])); - if (\array_key_exists('public', $service)) { + if (isset($service['public'])) { $alias->setPublic($service['public']); } elseif (isset($defaults['public'])) { $alias->setPublic($defaults['public']); From b2c9a6ea910b2a01d278e737bc4711c0486ae74e Mon Sep 17 00:00:00 2001 From: Mike Milano Date: Thu, 9 Apr 2020 08:07:46 -0700 Subject: [PATCH 09/10] [Twig][Mime] Removed extra quotes in missing package exception message --- src/Symfony/Bridge/Twig/Mime/NotificationEmail.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Bridge/Twig/Mime/NotificationEmail.php b/src/Symfony/Bridge/Twig/Mime/NotificationEmail.php index 6d9bffcfcc..e6b28c4db4 100644 --- a/src/Symfony/Bridge/Twig/Mime/NotificationEmail.php +++ b/src/Symfony/Bridge/Twig/Mime/NotificationEmail.php @@ -51,7 +51,7 @@ class NotificationEmail extends TemplatedEmail } if ($missingPackages) { - throw new \LogicException(sprintf('You cannot use "%s" if the "%s" Twig extension%s not available; try running "composer require "%s"".', static::class, implode('" and "', $missingPackages), \count($missingPackages) > 1 ? 's are' : ' is', implode(' ', array_keys($missingPackages)))); + throw new \LogicException(sprintf('You cannot use "%s" if the "%s" Twig extension%s not available; try running "%s".', static::class, implode('" and "', $missingPackages), \count($missingPackages) > 1 ? 's are' : ' is', 'composer require '.implode(' ', array_keys($missingPackages)))); } parent::__construct($headers, $body); From 8920f183fbb6489f622d94f5637e82bb36fc12fa Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Fri, 10 Apr 2020 22:35:26 +0200 Subject: [PATCH 10/10] [appveyor] bump cache --- phpunit | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpunit b/phpunit index c89d2e400b..fbce26d8ed 100755 --- a/phpunit +++ b/phpunit @@ -1,7 +1,7 @@ #!/usr/bin/env php