Skip to content

Commit 4aece4c

Browse files
authored
Merge pull request #27715 from nextcloud/revert-24295-perf/noid/router
Revert "First attempt to check against core routes before loading all app routes"
2 parents d1b0ccb + 8535340 commit 4aece4c

File tree

1 file changed

+12
-14
lines changed

1 file changed

+12
-14
lines changed

lib/private/Route/Router.php

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -233,29 +233,32 @@ public function create($name,
233233
* @throws \Exception
234234
* @return array
235235
*/
236-
public function findMatchingRoute(string $url, bool $loadAll = false): array {
237-
if (strpos($url, '/apps/') === 0) {
236+
public function findMatchingRoute(string $url): array {
237+
if (substr($url, 0, 6) === '/apps/') {
238238
// empty string / 'apps' / $app / rest of the route
239239
[, , $app,] = explode('/', $url, 4);
240240

241241
$app = \OC_App::cleanAppId($app);
242242
\OC::$REQUESTEDAPP = $app;
243243
$this->loadRoutes($app);
244-
} elseif (strpos($url, '/ocsapp/apps/') === 0) {
244+
} elseif (substr($url, 0, 13) === '/ocsapp/apps/') {
245245
// empty string / 'ocsapp' / 'apps' / $app / rest of the route
246246
[, , , $app,] = explode('/', $url, 5);
247247

248248
$app = \OC_App::cleanAppId($app);
249249
\OC::$REQUESTEDAPP = $app;
250250
$this->loadRoutes($app);
251-
} elseif (strpos($url, '/settings/') === 0) {
251+
} elseif (substr($url, 0, 10) === '/settings/') {
252252
$this->loadRoutes('settings');
253+
} elseif (substr($url, 0, 6) === '/core/') {
254+
\OC::$REQUESTEDAPP = $url;
255+
if (!\OC::$server->getConfig()->getSystemValueBool('maintenance') && !Util::needUpgrade()) {
256+
\OC_App::loadApps();
257+
}
258+
$this->loadRoutes('core');
259+
} else {
260+
$this->loadRoutes();
253261
}
254-
\OC::$REQUESTEDAPP = $url;
255-
if (!\OC::$server->getConfig()->getSystemValueBool('maintenance') && !Util::needUpgrade()) {
256-
\OC_App::loadApps();
257-
}
258-
$this->loadRoutes('core');
259262

260263
$matcher = new UrlMatcher($this->root, $this->context);
261264
try {
@@ -268,11 +271,6 @@ public function findMatchingRoute(string $url, bool $loadAll = false): array {
268271
try {
269272
$parameters = $matcher->match($url . '/');
270273
} catch (ResourceNotFoundException $newException) {
271-
// Attempt to fallback to load all routes if none of the above route patterns matches and the route is not in core
272-
if (!$loadAll) {
273-
$this->loadRoutes();
274-
return $this->findMatchingRoute($url, true);
275-
}
276274
// If we still didn't match a route, we throw the original exception
277275
throw $e;
278276
}

0 commit comments

Comments
 (0)