8000 bug #45948 [RateLimiter] Adding default empty string value on Securit… · symfony/symfony@2195545 · GitHub
[go: up one dir, main page]

Skip to content

Commit 2195545

Browse files
committed
bug #45948 [RateLimiter] Adding default empty string value on Security::LAST_USERNAME (David-Crty)
This PR was merged into the 5.4 branch. Discussion ---------- [RateLimiter] Adding default empty string value on Security::LAST_USERNAME Because `Security::LAST_USERNAME` not always exist, it can trigger a `preg_match(): Argument #2 ($subject) must be of type string` if $username is null The error is critical when having `declare(strict_types=1)`, to avoid issue when people create their own LoginRateLimiter from the DefaultLoginRateLimiter we can juste set a default empty string. | Q | A | ------------- | --- | Branch? | 5.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | License | MIT Commits ------- 0fdfcae [RateLimiter] Adding default empty value
2 parents c9a5155 + 0fdfcae commit 2195545

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/Symfony/Component/Security/Http/RateLimiter/DefaultLoginRateLimiter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public function __construct(RateLimiterFactory $globalFactory, RateLimiterFactor
3737

3838
protected function getLimiters(Request $request): array
3939
{
40-
$username = $request->attributes->get(Security::LAST_USERNAME);
40+
$username = $request->attributes->get(Security::LAST_USERNAME, '');
4141
$username = preg_match('//u', $username) ? mb_strtolower($username, 'UTF-8') : strtolower($username);
4242

4343
return [

0 commit comments

Comments
 (0)
0