]> source.dussan.org Git - nextcloud-server.git/commitdiff
fix(Router): Load attribute routes of all apps when not app is specified 47518/head
authorprovokateurin <kate@provokateurin.de>
Tue, 27 Aug 2024 07:00:09 +0000 (09:00 +0200)
committerbackportbot[bot] <backportbot[bot]@users.noreply.github.com>
Tue, 27 Aug 2024 10:51:52 +0000 (10:51 +0000)
Signed-off-by: provokateurin <kate@provokateurin.de>
lib/private/Route/Router.php

index b04b6a4d21cd7cf25e84047b31c0979c96f8d479..646d1d4e6ed6e030bc5c1e4654647b8863d7bc65 100644 (file)
@@ -111,9 +111,14 @@ class Router implements IRouter {
                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;
@@ -125,21 +130,9 @@ class Router implements IRouter {
                        } 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);
                        }
                }
 
@@ -413,6 +406,23 @@ class Router implements IRouter {
                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
         */