Files
BookStack/app/Http/Middleware/ClearPerRequestCaches.php
T
Dan Brown 8760481fc2 Layouts: Added testing for access control, and view impact
Added a new middlware to properly handle per-request in-memory caching
within the app.
2026-08-16 23:03:40 +01:00

31 lines
775 B
PHP

<?php
namespace BookStack\Http\Middleware;
use BookStack\View\ViewBlockManager;
use Closure;
use Illuminate\Http\Request;
/**
* Custom middleware to clear any local caches in the app which are created on a
* per-request basis. While this can be somewhat redundant in the normal PHP request
* lifecycle (since in memory caches are cleared on each request), this can be useful
* in testing and to prepare for future long-serving PHP runtimes.
*/
class ClearPerRequestCaches
{
public function __construct(
protected ViewBlockManager $viewBlockManager,
) {
}
public function handle(Request $request, Closure $next)
{
$response = $next($request);
$this->viewBlockManager->clearLocalCache();
return $response;
}
}