Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[10.x] Ability to configure default session block timeouts #48795

Merged
merged 2 commits into from
Oct 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/Illuminate/Session/Middleware/StartSession.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ protected function handleRequestWhileBlocking(Request $request, $session, Closur

$lockFor = $request->route() && $request->route()->locksFor()
? $request->route()->locksFor()
: 10;
: $this->manager->defaultRouteBlockLockSeconds();

$lock = $this->cache($this->manager->blockDriver())
->lock('session:'.$session->getId(), $lockFor)
Expand All @@ -90,7 +90,7 @@ protected function handleRequestWhileBlocking(Request $request, $session, Closur
$lock->block(
! is_null($request->route()->waitsFor())
? $request->route()->waitsFor()
: 10
: $this->manager->defaultRouteBlockWaitSeconds()
);

return $this->handleStatefulRequest($request, $session, $next);
Expand Down
20 changes: 20 additions & 0 deletions src/Illuminate/Session/SessionManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,26 @@ public function blockDriver()
return $this->config->get('session.block_store');
}

/**
* Get the maximum number of seconds the session lock should be held for.
*
* @return int
*/
public function defaultRouteBlockLockSeconds()
{
return $this->config->get('session.block_lock_seconds', 10);
}

/**
* Get the maximum number of seconds to wait while attempting to acquire a route block session lock.
*
* @return int
*/
public function defaultRouteBlockWaitSeconds()
{
return $this->config->get('session.block_wait_seconds', 10);
}

/**
* Get the session configuration.
*
Expand Down