Skip to content

Conversation

@butonic
Copy link
Member

@butonic butonic commented Jun 27, 2014

When registering an api call the collection gets set to

            OC::$server->getRouter()->useCollection('ocs');

My guess is it does not get reverted so when the next create rout call is executed is goes into the wrong collection. Fixes

@PVince81 @icewind1991 @schiesbn a quick review please.

@butonic butonic added this to the ownCloud 7 CE milestone Jun 27, 2014
@butonic
Copy link
Member Author

butonic commented Jun 27, 2014

without this the versions preview will use urls like http://localhost/core/index.php/ocs/preview?file=%2FNeue+Textdatei.txt&version=1403887662, with this they look like http://localhost/core/index.php/apps/files_versions/preview?file=%2FNeue+Textdatei.txt&version=1403890359

So there is definitely something wrong here. Adding to Milestone ownCloud 7 CE.

@LukasReschke
Copy link
Member

Related issue: #8375

@karlitschek
Copy link
Contributor

this looks good 👍

@MorrisJobke
Copy link
Contributor

I cannot reproduce the issue with current master.

@DeepDiver1975
Copy link
Member

@butonic wouldn't it make more sense to fix this globally by resetting the collection to root after ocs registration

@butonic
Copy link
Member Author

butonic commented Jun 29, 2014

@DeepDiver1975 I totally agree. But I chose the quick fix for this because I have not yet had a look at the API route registering code and wanted to make sure that it makes sense to restore the collection before the API register call returns.

@PVince81
Copy link
Contributor

PVince81 commented Jul 1, 2014

@DeepDiver1975 any further comments on this ?

For me the version previews already worked, so not sure how to reproduce the original issue.

@butonic
Copy link
Member Author

butonic commented Jul 1, 2014

@DeepDiver1975 @icewind1991 I now reset the route collection to 'root' because I cannot get the current route collection name from the route class. It smells horribly because the class behaves differently depending on state (the current route collection) and we have no way of asking from the outside which one that is. I'd say we either need a public getCurrentCollectionName() or we need to add a $collectionName parameter to create().

@icewind1991
Copy link
Contributor

My vote goes to getCurrentCollectionName() or getCurrentCollection()

@scrutinizer-notifier
Copy link

A new inspection was created.

@butonic
Copy link
Member Author

butonic commented Jul 1, 2014

@DeepDiver1975 @icewind1991 @bartv2 This should fix weird routing errors. Let's see what jenkins says

@ghost
Copy link

ghost commented Jul 1, 2014

🚀 Test Passed. 🚀
Refer to this link for build results: https://ci.owncloud.org/job/pull-request-analyser/5878/

@icewind1991
Copy link
Contributor

Code looks good 👍

@@ -72,6 +73,7 @@ public static function register($method, $url, $action, $app,
->requirements($requirements)
->action('OC_API', 'call');
self::$actions[$name] = array();
OC::$server->getRouter()->useCollection($oldCollection);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

because of $collectionName being initialized with null, null could be passed into useCollection() - I doubt this is giving us the right behavior.

@butonic

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, before the route.php is included the collection is set to the collection for the current app: https://github.com/owncloud/core/blob/fix_versions_preview/lib/private/route/router.php#L128

Registering api routes in routes.php is simply wrong. Well, not wrong, but it does not work reliably. They should go into api-routes.php or something. This PR at least resets the collection to what it was before setting an API route.

@DeepDiver1975
Copy link
Member

👍

DeepDiver1975 added a commit that referenced this pull request Jul 4, 2014
change order of registering api and capabilities to fix file version previews
@DeepDiver1975 DeepDiver1975 merged commit 2327d41 into master Jul 4, 2014
@DeepDiver1975 DeepDiver1975 deleted the fix_versions_preview branch July 4, 2014 13:25
@DeepDiver1975
Copy link
Member

I'll take care about backporting

@DeepDiver1975
Copy link
Member

backport to stable7:

commit f390ae53ba98ccbdfcc60aad2ab03a35bcf77b2c
Author: Jörn Friedrich Dreyer <jfd@butonic.de>
Date:   Tue Jul 1 16:45:00 2014 +0200

    introduce and use getCurrentConnection()

commit 195cf273f857d55f8b499cd872ab8e2d885b0891
Author: Jörn Friedrich Dreyer <jfd@butonic.de>
Date:   Tue Jul 1 14:21:20 2014 +0200

    reset collection to 'root' after adding a route to the api

commit 3a1c7182e678b6e42b132592b1470dfe3ef20464
Author: Jörn Friedrich Dreyer <jfd@butonic.de>
Date:   Fri Jun 27 19:22:10 2014 +0200

    change order of registering api and capabilities to fix file version previews

@lock lock bot locked as resolved and limited conversation to collaborators Aug 21, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants