Skip to content

Commit

Permalink
Don't create RateLimiterManager before the event fires.
Browse files Browse the repository at this point in the history
  • Loading branch information
EreMaijala committed May 30, 2024
1 parent 49e57f4 commit 7cb5b66
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions module/VuFind/src/VuFind/Bootstrapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -385,11 +385,12 @@ protected function initRateLimiter(): void
if (PHP_SAPI === 'cli') {
return;
}
$rateLimiterManager = $this->container->get(\VuFind\RateLimiter\RateLimiterManager::class);
if (!$rateLimiterManager->isEnabled()) {
return;
}
$callback = function ($event) use ($rateLimiterManager) {
$callback = function ($event) {
// Create rate limiter manager here so that we don't e.g. initialize the session too early:
$rateLimiterManager = $this->container->get(\VuFind\RateLimiter\RateLimiterManager::class);
if (!$rateLimiterManager->isEnabled()) {
return;
}
$result = $rateLimiterManager->check($event);
if (!$result['allow']) {
$response = $event->getResponse();
Expand Down

0 comments on commit 7cb5b66

Please sign in to comment.