diff options
author | William Desportes <williamdes@wdes.fr> | 2020-03-18 14:01:00 +0300 |
---|---|---|
committer | William Desportes <williamdes@wdes.fr> | 2020-03-28 12:38:11 +0300 |
commit | 898a526dfabf44b5b63392696d2ce22a50c47596 (patch) | |
tree | 9b1cb0165cb1dbd2b4223ebb59520845f7f816bd /index.php | |
parent | a7e8b0f67a4673bc7b4b0526ca7f5821d3b540a9 (diff) |
Use caching to speed up route parsing
Signed-off-by: William Desportes <williamdes@wdes.fr>
Diffstat (limited to 'index.php')
-rw-r--r-- | index.php | 11 |
1 files changed, 8 insertions, 3 deletions
@@ -7,7 +7,7 @@ declare(strict_types=1); use FastRoute\Dispatcher; use PhpMyAdmin\Message; use PhpMyAdmin\Response; -use function FastRoute\simpleDispatcher; +use function FastRoute\cachedDispatcher; if (! defined('ROOT_PATH')) { // phpcs:disable PSR1.Files.SideEffects @@ -15,7 +15,7 @@ if (! defined('ROOT_PATH')) { // phpcs:enable } -global $containerBuilder, $route; +global $containerBuilder, $route, $cfg; /** @var string $route */ $route = $_GET['route'] ?? $_POST['route'] ?? '/'; @@ -41,7 +41,12 @@ if ($route === '/import-status') { require_once ROOT_PATH . 'libraries/common.inc.php'; $routes = require ROOT_PATH . 'libraries/routes.php'; -$dispatcher = simpleDispatcher($routes); +/** @var \PhpMyAdmin\Config|null $config */ +$config = $GLOBALS['PMA_Config']; +$dispatcher = cachedDispatcher($routes, [ + 'cacheFile' => $config !== null ? $config->getTempDir('routing') . '/routes.cache' : null, + 'cacheDisabled' => ($cfg['environment'] ?? '') === 'development', +]); $routeInfo = $dispatcher->dispatch( $_SERVER['REQUEST_METHOD'], rawurldecode($route) |