From 0cb9d3a20801045d5553e303f1933ef82650923b Mon Sep 17 00:00:00 2001 From: slawkens Date: Thu, 2 Oct 2025 22:31:02 +0200 Subject: [PATCH] Fix routes_final cache --- system/router.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/system/router.php b/system/router.php index ec79f9b3..f876a9b2 100644 --- a/system/router.php +++ b/system/router.php @@ -88,9 +88,9 @@ if($logged && $account_logged && $account_logged->isLoaded()) { /** * Routes loading */ +$routesFinal = []; $dispatcher = FastRoute\cachedDispatcher(function (FastRoute\RouteCollector $r) { - global $cache; - $routesFinal = []; + global $cache, $routesFinal; foreach(getDatabasePages() as $page) { $routesFinal[] = ['*', $page, '__database__/' . $page, 100]; @@ -201,7 +201,9 @@ $dispatcher = FastRoute\cachedDispatcher(function (FastRoute\RouteCollector $r) } } - $cache->set('routes_final', serialize($routesFinal), 10 * 365 * 24 * 60 * 60); // 10 years / infinite + if ($cache->enabled()) { + $cache->set('routes_final', serialize($routesFinal), 10 * 365 * 24 * 60 * 60); // 10 years / infinite + } }, [ 'cacheFile' => CACHE . 'route.cache', @@ -227,9 +229,8 @@ if(!empty($page) && preg_match('/^[A-z0-9\/\-]+$/', $page)) { $foundRoute = false; - $routesFinal = []; $tmp = null; - if ($cache->fetch('routes_final', $tmp)) { + if ($cache->enabled() && $cache->fetch('routes_final', $tmp)) { $routesFinal = unserialize($tmp); }