Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/phpmyadmin/phpmyadmin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWilliam Desportes <williamdes@wdes.fr>2020-03-18 14:01:00 +0300
committerWilliam Desportes <williamdes@wdes.fr>2020-03-28 12:38:11 +0300
commit898a526dfabf44b5b63392696d2ce22a50c47596 (patch)
tree9b1cb0165cb1dbd2b4223ebb59520845f7f816bd /index.php
parenta7e8b0f67a4673bc7b4b0526ca7f5821d3b540a9 (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.php11
1 files changed, 8 insertions, 3 deletions
diff --git a/index.php b/index.php
index c1a2273cd0..e75d71f11d 100644
--- a/index.php
+++ b/index.php
@@ -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)