mirror of
https://github.com/slawkens/myaac.git
synced 2025-11-28 06:06:51 +01:00
Fix routes_final for prod env
This commit is contained in:
@@ -88,9 +88,9 @@ if($logged && $account_logged && $account_logged->isLoaded()) {
|
|||||||
/**
|
/**
|
||||||
* Routes loading
|
* Routes loading
|
||||||
*/
|
*/
|
||||||
$routesFinal = [];
|
|
||||||
$dispatcher = FastRoute\cachedDispatcher(function (FastRoute\RouteCollector $r) {
|
$dispatcher = FastRoute\cachedDispatcher(function (FastRoute\RouteCollector $r) {
|
||||||
global $routesFinal;
|
global $cache;
|
||||||
|
$routesFinal = [];
|
||||||
|
|
||||||
foreach(getDatabasePages() as $page) {
|
foreach(getDatabasePages() as $page) {
|
||||||
$routesFinal[] = ['*', $page, '__database__/' . $page, 100];
|
$routesFinal[] = ['*', $page, '__database__/' . $page, 100];
|
||||||
@@ -200,6 +200,8 @@ $dispatcher = FastRoute\cachedDispatcher(function (FastRoute\RouteCollector $r)
|
|||||||
log_append('router.log', $warning);
|
log_append('router.log', $warning);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$cache->set('routes_final', serialize($routesFinal), 10 * 365 * 24 * 60 * 60); // 10 years / infinite
|
||||||
},
|
},
|
||||||
[
|
[
|
||||||
'cacheFile' => CACHE . 'route.cache',
|
'cacheFile' => CACHE . 'route.cache',
|
||||||
@@ -224,6 +226,13 @@ if(!empty($page) && preg_match('/^[A-z0-9\/\-]+$/', $page)) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$foundRoute = false;
|
$foundRoute = false;
|
||||||
|
|
||||||
|
$routesFinal = [];
|
||||||
|
$tmp = null;
|
||||||
|
if ($cache->fetch('routes_final', $tmp)) {
|
||||||
|
$routesFinal = unserialize($tmp);
|
||||||
|
}
|
||||||
|
|
||||||
foreach ($routesFinal as $route) {
|
foreach ($routesFinal as $route) {
|
||||||
if ($page === $route[1]) {
|
if ($page === $route[1]) {
|
||||||
$file = $route[2];
|
$file = $route[2];
|
||||||
|
|||||||
Reference in New Issue
Block a user