diff options
author | John Molakvoæ <skjnldsv@users.noreply.github.com> | 2021-06-29 20:50:11 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-06-29 20:50:11 +0200 |
commit | 4aece4cae92cd81f6385016f58e5dd91e38b2658 (patch) | |
tree | fef97c788d6f2016edf0234da427ea94d8d6c0b8 | |
parent | d1b0ccb715305b08b7f426a287b9929a50c65e49 (diff) | |
parent | 8535340d9aae3c951a58587339e39506d4057118 (diff) | |
download | nextcloud-server-4aece4cae92cd81f6385016f58e5dd91e38b2658.tar.gz nextcloud-server-4aece4cae92cd81f6385016f58e5dd91e38b2658.zip |
Merge pull request #27715 from nextcloud/revert-24295-perf/noid/router
Revert "First attempt to check against core routes before loading all app routes"
-rw-r--r-- | lib/private/Route/Router.php | 26 |
1 files changed, 12 insertions, 14 deletions
diff --git a/lib/private/Route/Router.php b/lib/private/Route/Router.php index fddd64a7d48..0bccb8190cd 100644 --- a/lib/private/Route/Router.php +++ b/lib/private/Route/Router.php @@ -233,29 +233,32 @@ class Router implements IRouter { * @throws \Exception * @return array */ - public function findMatchingRoute(string $url, bool $loadAll = false): array { - if (strpos($url, '/apps/') === 0) { + public function findMatchingRoute(string $url): array { + if (substr($url, 0, 6) === '/apps/') { // empty string / 'apps' / $app / rest of the route [, , $app,] = explode('/', $url, 4); $app = \OC_App::cleanAppId($app); \OC::$REQUESTEDAPP = $app; $this->loadRoutes($app); - } elseif (strpos($url, '/ocsapp/apps/') === 0) { + } elseif (substr($url, 0, 13) === '/ocsapp/apps/') { // empty string / 'ocsapp' / 'apps' / $app / rest of the route [, , , $app,] = explode('/', $url, 5); $app = \OC_App::cleanAppId($app); \OC::$REQUESTEDAPP = $app; $this->loadRoutes($app); - } elseif (strpos($url, '/settings/') === 0) { + } elseif (substr($url, 0, 10) === '/settings/') { $this->loadRoutes('settings'); + } elseif (substr($url, 0, 6) === '/core/') { + \OC::$REQUESTEDAPP = $url; + if (!\OC::$server->getConfig()->getSystemValueBool('maintenance') && !Util::needUpgrade()) { + \OC_App::loadApps(); + } + $this->loadRoutes('core'); + } else { + $this->loadRoutes(); } - \OC::$REQUESTEDAPP = $url; - if (!\OC::$server->getConfig()->getSystemValueBool('maintenance') && !Util::needUpgrade()) { - \OC_App::loadApps(); - } - $this->loadRoutes('core'); $matcher = new UrlMatcher($this->root, $this->context); try { @@ -268,11 +271,6 @@ class Router implements IRouter { try { $parameters = $matcher->match($url . '/'); } catch (ResourceNotFoundException $newException) { - // Attempt to fallback to load all routes if none of the above route patterns matches and the route is not in core - if (!$loadAll) { - $this->loadRoutes(); - return $this->findMatchingRoute($url, true); - } // If we still didn't match a route, we throw the original exception throw $e; } |