Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove the matching on ancient /ocs routes #23820

Merged
merged 1 commit into from
Nov 4, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 5 additions & 32 deletions ocs/v1.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,45 +46,18 @@
use Symfony\Component\Routing\Exception\MethodNotAllowedException;

/*
* Try old routes first
* We first try the old routes since the appframework triggers more login stuff.
* Try the appframework routes
*/
try {
OC_App::loadApps(['session']);
OC_App::loadApps(['authentication']);
// load all apps to get all api routes properly setup
OC_App::loadApps();

OC::$server->getRouter()->match('/ocs'.\OC::$server->getRequest()->getRawPathInfo());

sleep(1);
OC::$server->getLogger()->info('This uses an old OCP\API::register construct. This will be removed in a future version of Nextcloud. Please migrate to the OCSController');

return;
} catch (ResourceNotFoundException $e) {
// Fall through the not found
} catch (MethodNotAllowedException $e) {
OC_API::setContentType();
http_response_code(405);
exit();
} catch (\OC\OCS\Exception $ex) {
OC_API::respond($ex->getResult(), OC_API::requestedFormat());
exit();
} catch (Throwable $ex) {
OC::$server->getLogger()->logException($ex);

OC_API::setContentType();
http_response_code(500);
exit();
}

/*
* Try the appframework routes
*/
try {
if (!\OC::$server->getUserSession()->isLoggedIn()) {
OC::handleLogin(\OC::$server->getRequest());
}

// load all apps to get all api routes properly setup
OC_App::loadApps();

OC::$server->getRouter()->match('/ocsapp'.\OC::$server->getRequest()->getRawPathInfo());
} catch (ResourceNotFoundException $e) {
OC_API::setContentType();
Expand Down