Skip to content

Commit

Permalink
Merge pull request #47518 from nextcloud/backport/47508/stable30
Browse files Browse the repository at this point in the history
[stable30] fix(Router): Load attribute routes of all apps when not app is specified
  • Loading branch information
AndyScherzinger authored Aug 27, 2024
2 parents 4ea8417 + c0f89e8 commit 15a0a3e
Showing 1 changed file with 24 additions and 14 deletions.
38 changes: 24 additions & 14 deletions lib/private/Route/Router.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,14 @@ public function loadRoutes($app = null) {
if ($this->loaded) {
return;
}
$this->eventLogger->start('route:load:' . $requestedApp, 'Loading Routes for ' . $requestedApp);
if (is_null($app)) {
$this->loaded = true;
$routingFiles = $this->getRoutingFiles();

foreach (\OC_App::getEnabledApps() as $enabledApp) {
$this->loadAttributeRoutes($enabledApp);
}
} else {
if (isset($this->loadedApps[$app])) {
return;
Expand All @@ -125,21 +130,9 @@ public function loadRoutes($app = null) {
} else {
$routingFiles = [];
}
}
$this->eventLogger->start('route:load:' . $requestedApp, 'Loading Routes for ' . $requestedApp);

if ($requestedApp !== null && in_array($requestedApp, \OC_App::getEnabledApps())) {
$routes = $this->getAttributeRoutes($requestedApp);
if (count($routes) > 0) {
$this->useCollection($requestedApp);
$this->setupRoutes($routes, $requestedApp);
$collection = $this->getCollection($requestedApp);
$this->root->addCollection($collection);

// Also add the OCS collection
$collection = $this->getCollection($requestedApp . '.ocs');
$collection->addPrefix('/ocsapp');
$this->root->addCollection($collection);
if ($this->appManager->isEnabledForUser($app)) {
$this->loadAttributeRoutes($app);
}
}

Expand Down Expand Up @@ -413,6 +406,23 @@ protected function fixLegacyRootName(string $routeName): string {
return $routeName;
}

private function loadAttributeRoutes(string $app): void {
$routes = $this->getAttributeRoutes($app);
if (count($routes) === 0) {
return;
}

$this->useCollection($app);
$this->setupRoutes($routes, $app);
$collection = $this->getCollection($app);
$this->root->addCollection($collection);

// Also add the OCS collection
$collection = $this->getCollection($app . '.ocs');
$collection->addPrefix('/ocsapp');
$this->root->addCollection($collection);
}

/**
* @throws ReflectionException
*/
Expand Down

0 comments on commit 15a0a3e

Please sign in to comment.