8000 bug #38661 [RateLimiter] Fix delete method of the cache storage (Greg… · symfony/symfony@76c22fa · GitHub
[go: up one dir, main page]

Skip to content 8000

Commit 76c22fa

Browse files
committed
bug #38661 [RateLimiter] Fix delete method of the cache storage (GregOriol, Nyholm)
This PR was merged into the 5.x branch. Discussion ---------- [RateLimiter] Fix delete method of the cache storage | Q | A | ------------- | --- | Branch? | 5.2 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | None | License | MIT This PR fixes a small issue with RateLimiter's cache storage and the delete method: all getItems are called with a sha1 of the id, but not the one for delete, which makes it miss the deletion. Commits ------- b61d9d1 minor 88c1e24 Added a test fb540bb Fix delete method on RateLimiter's cache storage
2 parents 6f0a897 + b61d9d1 commit 76c22fa

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

src/Symfony/Component/RateLimiter/Storage/CacheStorage.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,6 @@ public function fetch(string $limiterStateId): ?LimiterStateInterface
5252

5353
public function delete(string $limiterStateId): void
5454
{
55-
$this->pool->deleteItem($limiterStateId);
55+
$this->pool->deleteItem(sha1($limiterStateId));
5656
}
5757
}

src/Symfony/Component/RateLimiter/Tests/Storage/CacheStorageTest.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,4 +76,11 @@ public function testFetchNonExistingState()
7676

7777
$this->assertNull($this->storage->fetch('test'));
7878
}
79+
80+
public function testDelete()
81+
{
82+
$this->pool->expects($this->once())->method('deleteItem')->with(sha1('test'))->willReturn(true);
83+
84+
$this->storage->delete('test');
85+
}
7986
}

0 commit comments

Comments
 (0)
0