Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c1d281d

Browse files
feature #48275 [FrameworkBundle] Allow to avoid limit definition in a RateLimiter configuration when using the no_limit policy (alexandre-daubois)
This PR was merged into the 6.3 branch. Discussion ---------- [FrameworkBundle] Allow to avoid `limit` definition in a RateLimiter configuration when using the `no_limit` policy | Q | A | ------------- | --- | Branch? | 6.3 | Bug fix? | no | New feature? | yes | Deprecations? | no | Tickets | Fix #48268 | License | MIT | Doc PR | N/A As stated in the issue, DX will be improved if we can avoid setting a `limit` when using `no_limit` policy. Targets 6.3, as it can be considered as a feature. Commits ------- cd02eac [FrameworkBundle][DX] Allow to avoid `limit` definition in a RateLimiter configuration when using the `no_limit` policy
2 parents 7d22c79 + cd02eac commit c1d281d

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ CHANGELOG
55
---
66

77
* Add `DomCrawlerAssertionsTrait::assertSelectorCount(int $count, string $selector)`
8+
* Allow to avoid `limit` definition in a RateLimiter configuration when using the `no_limit` policy
89

910
6.2
1011
---

src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2104,7 +2104,6 @@ private function addRateLimiterSection(ArrayNodeDefinition $rootNode, callable $
21042104
->end()
21052105
->integerNode('limit')
21062106
->info('The maximum allowed hits in a fixed interval or burst')
2107-
->isRequired()
21082107
->end()
21092108
->scalarNode('interval')
21102109
->info('Configures the fixed interval if "policy" is set to "fixed_window" or "sliding_window". The value must be a number followed by "second", "minute", "hour", "day", "week" or "month" (or their plural equivalent).')
@@ -2119,6 +2118,10 @@ private function addRateLimiterSection(ArrayNodeDefinition $rootNode, callable $
21192118
->end()
21202119
->end()
21212120
->end()
2121+
->validate()
2122+
->ifTrue(function ($v) { return 'no_limit' !== $v['policy'] && !isset($v['limit']); })
2123+
->thenInvalid('A limit must be provided when using a policy different than "no_limit".')
2124+
->end()
21222125
->end()
21232126
->end()
21242127
->end()

0 commit comments

Comments
 (0)