Skip to content
Closed
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
7 changes: 7 additions & 0 deletions lib/private/Route/CachingRouter.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
use OCP\ICacheFactory;
use OCP\IConfig;
use OCP\IRequest;
use OCP\IUserSession;
use Psr\Container\ContainerInterface;
use Psr\Log\LoggerInterface;
use Symfony\Component\Routing\Exception\ResourceNotFoundException;
Expand All @@ -33,6 +34,7 @@ public function __construct(
IEventLogger $eventLogger,
ContainerInterface $container,
IAppManager $appManager,
private IUserSession $userSession,
) {
$this->cache = $cacheFactory->createLocal('route');
parent::__construct($logger, $request, $config, $eventLogger, $container, $appManager);
Expand Down Expand Up @@ -76,6 +78,11 @@ private function serializeRouteCollection(RouteCollection $collection): array {
public function findMatchingRoute(string $url): array {
$this->eventLogger->start('cacheroute:match', 'Match route');
$key = $this->context->getHost() . '#' . $this->context->getBaseUrl() . '#rootCollection';
$user = $this->userSession->getUser();
if ($user !== null) {
// Some routes depend on the user, for example due to app group restrictions
$key .= '#' . $user->getUID();
}
$cachedRoutes = $this->cache->get($key);
if (!$cachedRoutes) {
parent::loadRoutes();
Expand Down
Loading