From 5c3e184b1e96058c074c8d20a09ee3a708ba1f50 Mon Sep 17 00:00:00 2001 From: David Buchmann Date: Sun, 1 Sep 2024 09:07:16 +0200 Subject: [PATCH 1/2] throttle plugin requires a name --- CHANGELOG.md | 4 ++++ src/DependencyInjection/Configuration.php | 9 ++++++--- src/DependencyInjection/HttplugExtension.php | 5 ++--- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ccaff89d..a4012550 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,10 @@ The change log describes what is "Added", "Removed", "Changed" or "Fixed" betwee # Version 1 +# 1.34.1 - 2024-09-01 + +- The rate-limiter name in the throttle plugin configuration is required. + # 1.34.0 - 2024-06-17 - Support to configure the throttle plugin. diff --git a/src/DependencyInjection/Configuration.php b/src/DependencyInjection/Configuration.php index bd70c712..76b13751 100644 --- a/src/DependencyInjection/Configuration.php +++ b/src/DependencyInjection/Configuration.php @@ -616,7 +616,7 @@ private function addSharedPluginNodes(ArrayNodeDefinition $pluginNode, $disableA ->end(); // End stopwatch plugin - $error = $children->arrayNode('error') + $children->arrayNode('error') ->canBeEnabled() ->addDefaultsIfNotSet() ->children() @@ -625,11 +625,14 @@ private function addSharedPluginNodes(ArrayNodeDefinition $pluginNode, $disableA ->end(); // End error plugin - $throttle = $children->arrayNode('throttle') + $children->arrayNode('throttle') ->canBeEnabled() ->addDefaultsIfNotSet() ->children() - ->scalarNode('name')->end() + ->scalarNode('name') + ->info('The name of the configured symfony/rate-limiter to use') + ->isRequired() + ->end() ->scalarNode('key')->defaultNull()->end() ->integerNode('tokens')->defaultValue(1)->end() ->floatNode('max_time')->defaultNull()->end() diff --git a/src/DependencyInjection/HttplugExtension.php b/src/DependencyInjection/HttplugExtension.php index cdcbfcf0..ce88c008 100644 --- a/src/DependencyInjection/HttplugExtension.php +++ b/src/DependencyInjection/HttplugExtension.php @@ -299,14 +299,13 @@ private function configurePluginByName($name, Definition $definition, array $con throw new InvalidConfigurationException('You need to require the Throttle Plugin to be able to use it: "composer require php-http/throttle-plugin".'); } - $key = $config['name'] ? '.'.$config['name'] : ''; $container - ->register($serviceId.$key, LimiterInterface::class) + ->register($serviceId.$config['name'], LimiterInterface::class) ->setFactory([new Reference('limiter.'.$config['name']), 'create']) ->addArgument($config['key']) ->setPublic(false); - $definition->replaceArgument(0, new Reference($serviceId.$key)); + $definition->replaceArgument(0, new Reference($serviceId.$config['name'])); $definition->setArgument('$tokens', $config['tokens']); $definition->setArgument('$maxTime', $config['max_time']); From 64362f16b2aed00c5aedd4c8afcae0489e85f9e9 Mon Sep 17 00:00:00 2001 From: David Buchmann Date: Sun, 1 Sep 2024 09:16:43 +0200 Subject: [PATCH 2/2] fix build --- composer.json | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/composer.json b/composer.json index 3daeef71..adb2ed91 100644 --- a/composer.json +++ b/composer.json @@ -50,18 +50,19 @@ }, "require-dev": { "guzzlehttp/psr7": "^1.7 || ^2.0", - "matthiasnoback/symfony-dependency-injection-test": "^4.0 || ^5.0", + "matthiasnoback/symfony-config-test": "^4.3 || ^5.0", + "matthiasnoback/symfony-dependency-injection-test": "^4.3.1 || ^5.0", "nyholm/nsa": "^1.1", "nyholm/psr7": "^1.2.1", "php-http/cache-plugin": "^1.7", "php-http/mock-client": "^1.2", "php-http/promise": "^1.0", + "phpunit/phpunit": "^9.6", "symfony/browser-kit": "^4.4 || ^5.0 || ^6.0 || ^7.0", "symfony/cache": "^4.4 || ^5.0 || ^6.0 || ^7.0", "symfony/dom-crawler": "^4.4 || ^5.0 || ^6.0 || ^7.0", "symfony/framework-bundle": "^4.4 || ^5.0 || ^6.0 || ^7.0", "symfony/http-foundation": "^4.4.19 || ^5.0 || ^6.0 || ^7.0", - "symfony/phpunit-bridge": "^6.4.1", "symfony/stopwatch": "^4.4 || ^5.0 || ^6.0 || ^7.0", "symfony/twig-bundle": "^4.4 || ^5.0 || ^6.0 || ^7.0", "symfony/web-profiler-bundle": "^4.4.19 || ^5.0 || ^6.0 || ^7.0", @@ -97,7 +98,7 @@ }, "prefer-stable": false, "scripts": { - "test": "vendor/bin/simple-phpunit", - "test-ci": "vendor/bin/simple-phpunit --coverage-text --coverage-clover=build/coverage.xml" + "test": "vendor/bin/phpunit", + "test-ci": "vendor/bin/phpunit --coverage-text --coverage-clover=build/coverage.xml" } }