From 1ff042091a103d10f85a742658d021ea60a4f028 Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Fri, 28 Jun 2024 22:17:57 +0200 Subject: [PATCH 1/6] fix AssetMapper usage without assets enabled --- DependencyInjection/FrameworkExtension.php | 4 ++++ .../Fixtures/php/asset_mapper_without_assets.php | 10 ++++++++++ .../Fixtures/xml/asset_mapper_without_assets.xml | 14 ++++++++++++++ .../Fixtures/yml/asset_mapper_without_assets.yml | 8 ++++++++ .../FrameworkExtensionTestCase.php | 10 ++++++++++ 5 files changed, 46 insertions(+) create mode 100644 Tests/DependencyInjection/Fixtures/php/asset_mapper_without_assets.php create mode 100644 Tests/DependencyInjection/Fixtures/xml/asset_mapper_without_assets.xml create mode 100644 Tests/DependencyInjection/Fixtures/yml/asset_mapper_without_assets.yml diff --git a/DependencyInjection/FrameworkExtension.php b/DependencyInjection/FrameworkExtension.php index 84dbeabe9..83518061f 100644 --- a/DependencyInjection/FrameworkExtension.php +++ b/DependencyInjection/FrameworkExtension.php @@ -1334,6 +1334,10 @@ private function registerAssetMapperConfiguration(array $config, ContainerBuilde { $loader->load('asset_mapper.php'); + if (!$assetEnabled) { + $container->removeDefinition('asset_mapper.asset_package'); + } + if (!$httpClientEnabled) { $container->register('asset_mapper.http_client', HttpClientInterface::class) ->addTag('container.error') diff --git a/Tests/DependencyInjection/Fixtures/php/asset_mapper_without_assets.php b/Tests/DependencyInjection/Fixtures/php/asset_mapper_without_assets.php new file mode 100644 index 000000000..8a74333b1 --- /dev/null +++ b/Tests/DependencyInjection/Fixtures/php/asset_mapper_without_assets.php @@ -0,0 +1,10 @@ +loadFromExtension('framework', [ + 'annotations' => false, + 'asset_mapper' => null, + 'assets' => false, + 'handle_all_throwables' => true, + 'http_method_override' => false, + 'php_errors' => ['log' => true], +]); diff --git a/Tests/DependencyInjection/Fixtures/xml/asset_mapper_without_assets.xml b/Tests/DependencyInjection/Fixtures/xml/asset_mapper_without_assets.xml new file mode 100644 index 000000000..3976b1064 --- /dev/null +++ b/Tests/DependencyInjection/Fixtures/xml/asset_mapper_without_assets.xml @@ -0,0 +1,14 @@ + + + + + + + + + + diff --git a/Tests/DependencyInjection/Fixtures/yml/asset_mapper_without_assets.yml b/Tests/DependencyInjection/Fixtures/yml/asset_mapper_without_assets.yml new file mode 100644 index 000000000..51f302b66 --- /dev/null +++ b/Tests/DependencyInjection/Fixtures/yml/asset_mapper_without_assets.yml @@ -0,0 +1,8 @@ +framework: + annotations: false + asset_mapper: ~ + assets: false + handle_all_throwables: true + http_method_override: false + php_errors: + log: true diff --git a/Tests/DependencyInjection/FrameworkExtensionTestCase.php b/Tests/DependencyInjection/FrameworkExtensionTestCase.php index 55de5cc24..705ec5f31 100644 --- a/Tests/DependencyInjection/FrameworkExtensionTestCase.php +++ b/Tests/DependencyInjection/FrameworkExtensionTestCase.php @@ -2386,6 +2386,16 @@ public function testWebhookWithoutSerializer() ); } + public function testAssetMapperWithoutAssets() + { + $container = $this->createContainerFromFile('asset_mapper_without_assets'); + + $this->assertTrue($container->has('asset_mapper')); + $this->assertFalse($container->has('asset_mapper.asset_package')); + $this->assertFalse($container->has('assets.packages')); + $this->assertFalse($container->has('assets._default_package')); + } + protected function createContainer(array $data = []) { return new ContainerBuilder(new EnvPlaceholderParameterBag(array_merge([ From 65bb31002c28b882be912e77481167de0a2b83d2 Mon Sep 17 00:00:00 2001 From: Oskar Stark Date: Mon, 8 Jul 2024 21:30:21 +0200 Subject: [PATCH 2/6] Fix typo --- Command/SecretsDecryptToLocalCommand.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Command/SecretsDecryptToLocalCommand.php b/Command/SecretsDecryptToLocalCommand.php index 24bb242d9..1eaf3d0c9 100644 --- a/Command/SecretsDecryptToLocalCommand.php +++ b/Command/SecretsDecryptToLocalCommand.php @@ -50,7 +50,7 @@ protected function configure() %command.full_name% -When the option --force is provided, secrets that already exist in the local vault are overriden. +When the --force option is provided, secrets that already exist in the local vault are overridden. %command.full_name% --force EOF From 0a9f66cd53cb2578c9dff53645304ef313ecb63b Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Tue, 9 Jul 2024 22:57:15 +0200 Subject: [PATCH 3/6] use more entropy with uniqid() --- Tests/CacheWarmer/AnnotationsCacheWarmerTest.php | 2 +- Tests/CacheWarmer/ConfigBuilderCacheWarmerTest.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Tests/CacheWarmer/AnnotationsCacheWarmerTest.php b/Tests/CacheWarmer/AnnotationsCacheWarmerTest.php index eaee983b1..b082c4052 100644 --- a/Tests/CacheWarmer/AnnotationsCacheWarmerTest.php +++ b/Tests/CacheWarmer/AnnotationsCacheWarmerTest.php @@ -28,7 +28,7 @@ class AnnotationsCacheWarmerTest extends TestCase protected function setUp(): void { - $this->cacheDir = sys_get_temp_dir().'/'.uniqid(); + $this->cacheDir = sys_get_temp_dir().'/'.uniqid('', true); $fs = new Filesystem(); $fs->mkdir($this->cacheDir); parent::setUp(); diff --git a/Tests/CacheWarmer/ConfigBuilderCacheWarmerTest.php b/Tests/CacheWarmer/ConfigBuilderCacheWarmerTest.php index 85975c621..f44eefedf 100644 --- a/Tests/CacheWarmer/ConfigBuilderCacheWarmerTest.php +++ b/Tests/CacheWarmer/ConfigBuilderCacheWarmerTest.php @@ -36,7 +36,7 @@ class ConfigBuilderCacheWarmerTest extends TestCase protected function setUp(): void { - $this->varDir = sys_get_temp_dir().'/'.uniqid(); + $this->varDir = sys_get_temp_dir().'/'.uniqid('', true); $fs = new Filesystem(); $fs->mkdir($this->varDir); } From 35bab8428616546cec9166c685be151677b80894 Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Tue, 23 Jul 2024 08:10:24 +0200 Subject: [PATCH 4/6] move adding detailed JSON error messages to the validate phase --- DependencyInjection/Configuration.php | 2 +- .../DependencyInjection/ConfigurationTest.php | 58 +++++++++++++++++++ 2 files changed, 59 insertions(+), 1 deletion(-) diff --git a/DependencyInjection/Configuration.php b/DependencyInjection/Configuration.php index ad3521608..4f23d4396 100644 --- a/DependencyInjection/Configuration.php +++ b/DependencyInjection/Configuration.php @@ -1197,7 +1197,7 @@ private function addSerializerSection(ArrayNodeDefinition $rootNode, callable $e ->arrayNode('default_context') ->normalizeKeys(false) ->useAttributeAsKey('name') - ->beforeNormalization() + ->validate() ->ifTrue(fn () => $this->debug && class_exists(JsonParser::class)) ->then(fn (array $v) => $v + [JsonDecode::DETAILED_ERROR_MESSAGES => true]) ->end() diff --git a/Tests/DependencyInjection/ConfigurationTest.php b/Tests/DependencyInjection/ConfigurationTest.php index ca34ce109..1e4ee15a6 100644 --- a/Tests/DependencyInjection/ConfigurationTest.php +++ b/Tests/DependencyInjection/ConfigurationTest.php @@ -13,6 +13,7 @@ use Doctrine\DBAL\Connection; use PHPUnit\Framework\TestCase; +use Seld\JsonLint\JsonParser; use Symfony\Bundle\FrameworkBundle\DependencyInjection\Configuration; use Symfony\Bundle\FullStack; use Symfony\Component\Cache\Adapter\DoctrineAdapter; @@ -566,6 +567,63 @@ public function testEnabledLockNeedsResources() ]); } + public function testSerializerJsonDetailedErrorMessagesEnabledWhenDefaultContextIsConfigured() + { + $processor = new Processor(); + $config = $processor->processConfiguration(new Configuration(true), [ + [ + 'serializer' => [ + 'default_context' => [ + 'foo' => 'bar', + ], + ], + ], + ]); + + $this->assertSame(['foo' => 'bar', JsonDecode::DETAILED_ERROR_MESSAGES => true], $config['serializer']['default_context'] ?? []); + } + + public function testSerializerJsonDetailedErrorMessagesInDefaultContextCanBeDisabled() + { + $processor = new Processor(); + $config = $processor->processConfiguration(new Configuration(true), [ + [ + 'serializer' => [ + 'default_context' => [ + 'foo' => 'bar', + JsonDecode::DETAILED_ERROR_MESSAGES => false, + ], + ], + ], + ]); + + $this->assertSame(['foo' => 'bar', JsonDecode::DETAILED_ERROR_MESSAGES => false], $config['serializer']['default_context'] ?? []); + } + + public function testSerializerJsonDetailedErrorMessagesInDefaultContextCanBeDisabledWithSeveralConfigsBeingMerged() + { + $processor = new Processor(); + $config = $processor->processConfiguration(new Configuration(true), [ + [ + 'serializer' => [ + 'default_context' => [ + 'foo' => 'bar', + JsonDecode::DETAILED_ERROR_MESSAGES => false, + ], + ], + ], + [ + 'serializer' => [ + 'default_context' => [ + 'foobar' => 'baz', + ], + ], + ], + ]); + + $this->assertSame(['foo' => 'bar', JsonDecode::DETAILED_ERROR_MESSAGES => false, 'foobar' => 'baz'], $config['serializer']['default_context'] ?? []); + } + protected static function getBundleDefaultConfig() { return [ From 21876ac664ca543a93cafbe11fe46567f7e54794 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Fri, 26 Jul 2024 15:15:05 +0200 Subject: [PATCH 5/6] Fix merge --- Tests/DependencyInjection/ConfigurationTest.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Tests/DependencyInjection/ConfigurationTest.php b/Tests/DependencyInjection/ConfigurationTest.php index 1e4ee15a6..1d48dce8f 100644 --- a/Tests/DependencyInjection/ConfigurationTest.php +++ b/Tests/DependencyInjection/ConfigurationTest.php @@ -572,6 +572,7 @@ public function testSerializerJsonDetailedErrorMessagesEnabledWhenDefaultContext $processor = new Processor(); $config = $processor->processConfiguration(new Configuration(true), [ [ + 'http_method_override' => false, 'serializer' => [ 'default_context' => [ 'foo' => 'bar', @@ -588,6 +589,7 @@ public function testSerializerJsonDetailedErrorMessagesInDefaultContextCanBeDisa $processor = new Processor(); $config = $processor->processConfiguration(new Configuration(true), [ [ + 'http_method_override' => false, 'serializer' => [ 'default_context' => [ 'foo' => 'bar', @@ -605,6 +607,7 @@ public function testSerializerJsonDetailedErrorMessagesInDefaultContextCanBeDisa $processor = new Processor(); $config = $processor->processConfiguration(new Configuration(true), [ [ + 'http_method_override' => false, 'serializer' => [ 'default_context' => [ 'foo' => 'bar', From 6cbdb0cc3ddbb63499262cd3036882b08ee2690b Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Fri, 26 Jul 2024 15:24:20 +0200 Subject: [PATCH 6/6] Fix merge (bis) --- Tests/DependencyInjection/ConfigurationTest.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Tests/DependencyInjection/ConfigurationTest.php b/Tests/DependencyInjection/ConfigurationTest.php index 1d48dce8f..171cfedc4 100644 --- a/Tests/DependencyInjection/ConfigurationTest.php +++ b/Tests/DependencyInjection/ConfigurationTest.php @@ -573,6 +573,8 @@ public function testSerializerJsonDetailedErrorMessagesEnabledWhenDefaultContext $config = $processor->processConfiguration(new Configuration(true), [ [ 'http_method_override' => false, + 'handle_all_throwables' => true, + 'php_errors' => ['log' => true], 'serializer' => [ 'default_context' => [ 'foo' => 'bar', @@ -590,6 +592,8 @@ public function testSerializerJsonDetailedErrorMessagesInDefaultContextCanBeDisa $config = $processor->processConfiguration(new Configuration(true), [ [ 'http_method_override' => false, + 'handle_all_throwables' => true, + 'php_errors' => ['log' => true], 'serializer' => [ 'default_context' => [ 'foo' => 'bar', @@ -608,6 +612,8 @@ public function testSerializerJsonDetailedErrorMessagesInDefaultContextCanBeDisa $config = $processor->processConfiguration(new Configuration(true), [ [ 'http_method_override' => false, + 'handle_all_throwables' => true, + 'php_errors' => ['log' => true], 'serializer' => [ 'default_context' => [ 'foo' => 'bar', pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy