Fix loading order for OCS endpoints

The loading order can have side effects in the way how apps register
plugins, listeners, etc.

Recently the order had been changed as part of cleaning up old code, but
caused apps to break.

This brings back the old app loading order to guarantee that apps won't
break, even though it might not semantically make sense.

Signed-off-by: Vincent Petry <vincent@nextcloud.com>
This commit is contained in:
Vincent Petry 2020-12-10 08:20:20 +01:00
parent c8e0f3015f
commit 5f405e1454
No known key found for this signature in database
GPG Key ID: E055D6A4D513575C
1 changed files with 6 additions and 3 deletions

View File

@ -51,13 +51,16 @@ use Symfony\Component\Routing\Exception\MethodNotAllowedException;
try { try {
OC_App::loadApps(['session']); OC_App::loadApps(['session']);
OC_App::loadApps(['authentication']); OC_App::loadApps(['authentication']);
// load all apps to get all api routes properly setup
// FIXME: this should ideally appear after handleLogin but will cause
// side effects in existing apps
OC_App::loadApps();
if (!\OC::$server->getUserSession()->isLoggedIn()) { if (!\OC::$server->getUserSession()->isLoggedIn()) {
OC::handleLogin(\OC::$server->getRequest()); OC::handleLogin(\OC::$server->getRequest());
} }
// load all apps to get all api routes properly setup
OC_App::loadApps();
OC::$server->get(\OC\Route\Router::class)->match('/ocsapp'.\OC::$server->getRequest()->getRawPathInfo()); OC::$server->get(\OC\Route\Router::class)->match('/ocsapp'.\OC::$server->getRequest()->getRawPathInfo());
} catch (ResourceNotFoundException $e) { } catch (ResourceNotFoundException $e) {
OC_API::setContentType(); OC_API::setContentType();