mirror of
https://github.com/nextcloud/server.git
synced 2026-01-29 14:32:58 +00:00
When a user has an active session only the apps that are enabled for the user are initially loaded. In order to cache the routes the routes for all apps are loaded, but routes defined in routes.php are taken into account only if the app was already loaded. Therefore, when the routes were cached in a request by a user with an active session only the routes for apps enabled for that user were cached, and those routes were used by any other user, independently of which apps they had access to. To solve that now all the enabled apps are explicitly loaded before caching the routes. Note that this did not affect routes defined using annotations on the controller files; in that case the loaded routes do not depend on the previously loaded apps, as it explicitly checks all the enabled apps. Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
43 lines
963 B
PHP
43 lines
963 B
PHP
<?php
|
|
|
|
/**
|
|
* SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors
|
|
* SPDX-License-Identifier: AGPL-3.0-or-later
|
|
*/
|
|
namespace OCA\Testing\Controller;
|
|
|
|
use OCP\App\AppPathNotFoundException;
|
|
use OCP\App\IAppManager;
|
|
use OCP\AppFramework\Http;
|
|
use OCP\AppFramework\Http\DataResponse;
|
|
use OCP\AppFramework\OCSController;
|
|
use OCP\IRequest;
|
|
|
|
class RoutesController extends OCSController {
|
|
|
|
public function __construct(
|
|
string $appName,
|
|
IRequest $request,
|
|
private IAppManager $appManager,
|
|
) {
|
|
parent::__construct($appName, $request);
|
|
}
|
|
|
|
public function getRoutesInRoutesPhp(string $app): DataResponse {
|
|
try {
|
|
$appPath = $this->appManager->getAppPath($app);
|
|
} catch (AppPathNotFoundException) {
|
|
return new DataResponse([], Http::STATUS_NOT_FOUND);
|
|
}
|
|
|
|
$file = $appPath . '/appinfo/routes.php';
|
|
if (!file_exists($file)) {
|
|
return new DataResponse();
|
|
}
|
|
|
|
$routes = include $file;
|
|
|
|
return new DataResponse($routes);
|
|
}
|
|
}
|