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

Kill some of the old sharing code related to share backends #26608

Merged
merged 21 commits into from
Oct 18, 2018

Conversation

PVince81
Copy link
Contributor

@PVince81 PVince81 commented Nov 11, 2016

Description

Remove the "File" and "Folder" item type and share backends from files_sharing.
These should not be needed any more when using the OCS Share API.

Also removes any reference to file/folder in the old share API in \OC\Share (where possible), so that the old sharing stays only for other types like contacts/etc. (another approach would be to rewire these API to the new API if a file/folder item type is given ?)

Also remove most methods in \OC:Share class

Related Issue

General cleanup issue: #22209
Issue about those backends using oc_filecache: #26607

Motivation and Context

Removes the old code,

How Has This Been Tested?

  • Quick test in the web UI, sharing still seems to work, so does "unshare from self".
  • A quick run of integration tests locally showed that many calls still work (but my env is a bit broken so want to see that run on CI).
  • Will need manual testing of all share scenarios (and/or complete these as integration tests)
  • Retest fed sharing

Screenshots (if appropriate):

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

TODOs:

  • port all file share related tests that use shareItem with file/folder to use the share manager instead

@DeepDiver1975 @jvillafanez

@mention-bot
Copy link

@PVince81, thanks for your PR! By analyzing the history of the files in this pull request, we identified @schiessle, @DeepDiver1975 and @nickvergessen to be potential reviewers.

@PVince81
Copy link
Contributor Author

Looks like View::isTargetAllowed is a big blocker for many tests.
Might want to move this to the SharedMount implementation and add that method on the MoveableMount interface.

But the bigger problem is that it seems that the share manager has no replacement for \OCP\Share::getItemShared

@PVince81 PVince81 force-pushed the remove-file-share-backends branch from 8b2a6c4 to 354e756 Compare November 11, 2016 16:34
@PVince81
Copy link
Contributor Author

Solved a few test issues by porting the tests to the new API.
Unfortunately most are failing due to #26608 (comment). Need a good solution.

@PVince81
Copy link
Contributor Author

PVince81 commented Nov 11, 2016

@PVince81
Copy link
Contributor Author

PVince81 commented Nov 11, 2016

Remaining to port:

apps/files_sharing/lib/ExpireSharesJob.php:                     \OCP\Share::unshare($share['item_type'], $share['file_source'], \OCP\Share::SHARE_TYPE_LINK, null, $share['uid_owner']);
apps/files_sharing/lib/Helper.php:              $linkItem = \OCP\Share::getShareByToken($token, !$password);
apps/files_sharing/lib/Helper.php:              $rootLinkItem = \OCP\Share::resolveReShare($linkItem);
lib/private/Encryption/File.php:                        $resultForParents = \OCP\Share::getUsersSharingFile($parent, $owner);
lib/private/Encryption/File.php:                $resultForFile = \OCP\Share::getUsersSharingFile($ownerPath, $owner, false, false, false);
lib/private/Files/View.php:             $shares = \OCP\Share::getItemShared(
lib/private/Share/Share.php:            if ($checkPasswordProtection && !\OCP\Share::checkPasswordProtectedShare($row)) {

@PVince81 PVince81 force-pushed the remove-file-share-backends branch from 354e756 to cb9184f Compare November 11, 2016 17:58
@PVince81
Copy link
Contributor Author

PVince81 commented Nov 11, 2016

@PVince81 PVince81 force-pushed the remove-file-share-backends branch from cb9184f to 0b07d32 Compare November 11, 2016 18:40
@PVince81
Copy link
Contributor Author

PVince81 commented Nov 11, 2016

@PVince81
Copy link
Contributor Author

PVince81 commented Nov 14, 2016

  • kill \OCP\Share altogether as @DeepDiver1975 told me that it's not used by calendar and contacts any more 🎉 => can't kill before ajax/share.php is gone due to gallery app

@PVince81 PVince81 changed the title Remove old file share backends Kill old sharing code Nov 14, 2016
@PVince81 PVince81 force-pushed the remove-file-share-backends branch from 0b07d32 to bd2008a Compare November 21, 2016 10:09
@PVince81 PVince81 force-pushed the remove-file-share-backends branch from bd2008a to 2d2c5f5 Compare November 29, 2016 17:37
@PVince81
Copy link
Contributor Author

Rebased as the isTargetAllowed fix was merged. Now there should be much less test failures.

@PVince81
Copy link
Contributor Author

18:44:53 1) OCA\Files_Sharing\Tests\ApiTest::testDefaultExpireDate
18:44:53 Exception: Sharing backend for file not found
18:44:53 
18:44:53 /var/lib/jenkins/workspace/owncloud-core_core_PR-26608-7HTQSAV7ASDXHK3HEP454Z4KEUYQXFTEM4XUGRAL27I4X6LVM6NQ/lib/private/Share/Share.php:1474
18:44:53 /var/lib/jenkins/workspace/owncloud-core_core_PR-26608-7HTQSAV7ASDXHK3HEP454Z4KEUYQXFTEM4XUGRAL27I4X6LVM6NQ/lib/private/Share/Share.php:603
18:44:53 /var/lib/jenkins/workspace/owncloud-core_core_PR-26608-7HTQSAV7ASDXHK3HEP454Z4KEUYQXFTEM4XUGRAL27I4X6LVM6NQ/lib/public/Share.php:267
18:44:53 /var/lib/jenkins/workspace/owncloud-core_core_PR-26608-7HTQSAV7ASDXHK3HEP454Z4KEUYQXFTEM4XUGRAL27I4X6LVM6NQ/apps/files_sharing/tests/ApiTest.php:1399
18:44:53 
18:44:53 2) OCA\Files_Sharing\Tests\ExpireSharesJobTest::testExpireLinkShare with data set #2 (true, 'P1D', false, true)
18:44:53 Exception: Sharing backend for folder not found
18:44:53 
18:44:53 /var/lib/jenkins/workspace/owncloud-core_core_PR-26608-7HTQSAV7ASDXHK3HEP454Z4KEUYQXFTEM4XUGRAL27I4X6LVM6NQ/lib/private/Share/Share.php:1474
18:44:53 /var/lib/jenkins/workspace/owncloud-core_core_PR-26608-7HTQSAV7ASDXHK3HEP454Z4KEUYQXFTEM4XUGRAL27I4X6LVM6NQ/lib/private/Share/Share.php:863
18:44:53 /var/lib/jenkins/workspace/owncloud-core_core_PR-26608-7HTQSAV7ASDXHK3HEP454Z4KEUYQXFTEM4XUGRAL27I4X6LVM6NQ/lib/public/Share.php:281
18:44:53 /var/lib/jenkins/workspace/owncloud-core_core_PR-26608-7HTQSAV7ASDXHK3HEP454Z4KEUYQXFTEM4XUGRAL27I4X6LVM6NQ/apps/files_sharing/lib/ExpireSharesJob.php:71
18:44:53 /var/lib/jenkins/workspace/owncloud-core_core_PR-26608-7HTQSAV7ASDXHK3HEP454Z4KEUYQXFTEM4XUGRAL27I4X6LVM6NQ/apps/files_sharing/tests/ExpireSharesJobTest.php:175
18:44:53 
18:44:53 3) OCA\Files_Sharing\Tests\ExpireSharesJobTest::testExpireLinkShare with data set #4 (true, 'P1W', false, true)
18:44:53 Exception: Sharing backend for folder not found
18:44:53 
18:44:53 /var/lib/jenkins/workspace/owncloud-core_core_PR-26608-7HTQSAV7ASDXHK3HEP454Z4KEUYQXFTEM4XUGRAL27I4X6LVM6NQ/lib/private/Share/Share.php:1474
18:44:53 /var/lib/jenkins/workspace/owncloud-core_core_PR-26608-7HTQSAV7ASDXHK3HEP454Z4KEUYQXFTEM4XUGRAL27I4X6LVM6NQ/lib/private/Share/Share.php:863
18:44:53 /var/lib/jenkins/workspace/owncloud-core_core_PR-26608-7HTQSAV7ASDXHK3HEP454Z4KEUYQXFTEM4XUGRAL27I4X6LVM6NQ/lib/public/Share.php:281
18:44:53 /var/lib/jenkins/workspace/owncloud-core_core_PR-26608-7HTQSAV7ASDXHK3HEP454Z4KEUYQXFTEM4XUGRAL27I4X6LVM6NQ/apps/files_sharing/lib/ExpireSharesJob.php:71
18:44:53 /var/lib/jenkins/workspace/owncloud-core_core_PR-26608-7HTQSAV7ASDXHK3HEP454Z4KEUYQXFTEM4XUGRAL27I4X6LVM6NQ/apps/files_sharing/tests/ExpireSharesJobTest.php:175
18:44:53 
18:44:53 4) OCA\Files_Sharing\Tests\ExpireSharesJobTest::testExpireLinkShare with data set #6 (true, 'P1M', false, true)
18:44:53 Exception: Sharing backend for folder not found
18:44:53 
18:44:53 /var/lib/jenkins/workspace/owncloud-core_core_PR-26608-7HTQSAV7ASDXHK3HEP454Z4KEUYQXFTEM4XUGRAL27I4X6LVM6NQ/lib/private/Share/Share.php:1474
18:44:53 /var/lib/jenkins/workspace/owncloud-core_core_PR-26608-7HTQSAV7ASDXHK3HEP454Z4KEUYQXFTEM4XUGRAL27I4X6LVM6NQ/lib/private/Share/Share.php:863
18:44:53 /var/lib/jenkins/workspace/owncloud-core_core_PR-26608-7HTQSAV7ASDXHK3HEP454Z4KEUYQXFTEM4XUGRAL27I4X6LVM6NQ/lib/public/Share.php:281
18:44:53 /var/lib/jenkins/workspace/owncloud-core_core_PR-26608-7HTQSAV7ASDXHK3HEP454Z4KEUYQXFTEM4XUGRAL27I4X6LVM6NQ/apps/files_sharing/lib/ExpireSharesJob.php:71
18:44:53 /var/lib/jenkins/workspace/owncloud-core_core_PR-26608-7HTQSAV7ASDXHK3HEP454Z4KEUYQXFTEM4XUGRAL27I4X6LVM6NQ/apps/files_sharing/tests/ExpireSharesJobTest.php:175
18:44:53 
18:44:53 5) OCA\Files_Sharing\Tests\ExpireSharesJobTest::testExpireLinkShare with data set #8 (true, 'P1Y', false, true)
18:44:53 Exception: Sharing backend for folder not found
18:44:53 
18:44:53 /var/lib/jenkins/workspace/owncloud-core_core_PR-26608-7HTQSAV7ASDXHK3HEP454Z4KEUYQXFTEM4XUGRAL27I4X6LVM6NQ/lib/private/Share/Share.php:1474
18:44:53 /var/lib/jenkins/workspace/owncloud-core_core_PR-26608-7HTQSAV7ASDXHK3HEP454Z4KEUYQXFTEM4XUGRAL27I4X6LVM6NQ/lib/private/Share/Share.php:863
18:44:53 /var/lib/jenkins/workspace/owncloud-core_core_PR-26608-7HTQSAV7ASDXHK3HEP454Z4KEUYQXFTEM4XUGRAL27I4X6LVM6NQ/lib/public/Share.php:281
18:44:53 /var/lib/jenkins/workspace/owncloud-core_core_PR-26608-7HTQSAV7ASDXHK3HEP454Z4KEUYQXFTEM4XUGRAL27I4X6LVM6NQ/apps/files_sharing/lib/ExpireSharesJob.php:71
18:44:53 /var/lib/jenkins/workspace/owncloud-core_core_PR-26608-7HTQSAV7ASDXHK3HEP454Z4KEUYQXFTEM4XUGRAL27I4X6LVM6NQ/apps/files_sharing/tests/ExpireSharesJobTest.php:175

@PVince81
Copy link
Contributor Author

apps/files_sharing/tests/ApiTest.php will need more work as it seems to test older APIs

@PVince81 PVince81 force-pushed the remove-file-share-backends branch from 2d2c5f5 to 423cbe8 Compare December 23, 2016 07:09
@PVince81
Copy link
Contributor Author

Note: we can't kill OCP\Share without killing ajax/share.php yet, so I'd do that in a separate PR.
And we can't kill ajax/share.php as the gallery app is still using some of these old endpoints.

@PVince81
Copy link
Contributor Author

Last failure:

10:06:59 1) OCA\Files_Sharing\Tests\ApiTest::testDefaultExpireDate
10:06:59 Exception: Sharing backend for file not found
10:06:59 
10:06:59 /var/lib/jenkins/workspace/owncloud-core_core_PR-26608-7HTQSAV7ASDXHK3HEP454Z4KEUYQXFTEM4XUGRAL27I4X6LVM6NQ/lib/private/Share/Share.php:1474
10:06:59 /var/lib/jenkins/workspace/owncloud-core_core_PR-26608-7HTQSAV7ASDXHK3HEP454Z4KEUYQXFTEM4XUGRAL27I4X6LVM6NQ/lib/private/Share/Share.php:603
10:06:59 /var/lib/jenkins/workspace/owncloud-core_core_PR-26608-7HTQSAV7ASDXHK3HEP454Z4KEUYQXFTEM4XUGRAL27I4X6LVM6NQ/lib/public/Share.php:267
10:06:59 /var/lib/jenkins/workspace/owncloud-core_core_PR-26608-7HTQSAV7ASDXHK3HEP454Z4KEUYQXFTEM4XUGRAL27I4X6LVM6NQ/apps/files_sharing/tests/ApiTest.php:1399

Some old tests can be deleted but need to check that the new code has these tests too for the new sharing API.

@PVince81
Copy link
Contributor Author

It is also likely that merging this PR would break gallery sharing, so need to verify that it doesn't.

@PVince81 PVince81 force-pushed the remove-file-share-backends branch from 2a1ccb0 to 152ef00 Compare October 18, 2018 06:45
@PVince81
Copy link
Contributor Author

Rebased since #32494 was merged. Expecting all tests to be green now.

@PVince81
Copy link
Contributor Author

seems I forgot to grep in "settings" when killing APIs:

{"reqId":"teYh83ZViCZbzxzQ9rlo","level":3,"time":"2018-10-18T12:36:58+00:00","remoteAddr":"127.0.0.1","user":"admin","app":"index","method":"GET","url":"\/owncloud\/index.php\/settings\/admin?sectionid=sharing","message":"Exception: {\"Exception\":\"Error\",\"Message\":\"Call to undefined method OC\\\\Share\\\\Share::shareWithGroupMembersOnly()\",\"Code\":0,\"Trace\":\"#0 \\\/srv\\\/www\\\/htdocs\\\/owncloud\\\/settings\\\/Panels\\\/Admin\\\/FileSharing.php(96): OC\\\\Settings\\\\Panels\\\\Helper->shareWithGroupMembersOnly()\\n#1 \\\/srv\\\/www\\\/htdocs\\\/owncloud\\\/settings\\\/Controller\\\/SettingsPageController.php(167): OC\\\\Settings\\\\Panels\\\\Admin\\\\FileSharing->getPanel()\\n#2 \\\/srv\\\/www\\\/htdocs\\\/owncloud\\\/settings\\\/Controller\\\/SettingsPageController.php(104): OC\\\\Settings\\\\Controller\\\\SettingsPageController->getPanelsData(Array)\\n#3 \\\/srv\\\/www\\\/htdocs\\\/owncloud\\\/lib\\\/private\\\/AppFramework\\\/Http\\\/Dispatcher.php(153): OC\\\\Settings\\\\Controller\\\\SettingsPageController->getAdmin('sharing')\\n#4 \\\/srv\\\/www\\\/htdocs\\\/owncloud\\\/lib\\\/private\\\/AppFramework\\\/Http\\\/Dispatcher.php(85): OC\\\\AppFramework\\\\Http\\\\Dispatcher->executeController(Object(OC\\\\Settings\\\\Controller\\\\SettingsPageController), 'getAdmin')\\n#5 \\\/srv\\\/www\\\/htdocs\\\/owncloud\\\/lib\\\/private\\\/AppFramework\\\/App.php(100): OC\\\\AppFramework\\\\Http\\\\Dispatcher->dispatch(Object(OC\\\\Settings\\\\Controller\\\\SettingsPageController), 'getAdmin')\\n#6 \\\/srv\\\/www\\\/htdocs\\\/owncloud\\\/lib\\\/private\\\/AppFramework\\\/Routing\\\/RouteActionHandler.php(47): OC\\\\AppFramework\\\\App::main('SettingsPageCon...', 'getAdmin', Object(OC\\\\AppFramework\\\\DependencyInjection\\\\DIContainer), Array)\\n#7 \\\/srv\\\/www\\\/htdocs\\\/owncloud\\\/lib\\\/private\\\/Route\\\/Router.php(342): OC\\\\AppFramework\\\\Routing\\\\RouteActionHandler->__invoke(Array)\\n#8 \\\/srv\\\/www\\\/htdocs\\\/owncloud\\\/lib\\\/base.php(907): OC\\\\Route\\\\Router->match('\\\/settings\\\/admin')\\n#9 \\\/srv\\\/www\\\/htdocs\\\/owncloud\\\/index.php(54): OC::handleRequest()\\n#10 {main}\",\"File\":\"\\\/srv\\\/www\\\/htdocs\\\/owncloud\\\/settings\\\/Panels\\\/Helper.php\",\"Line\":38}"}
{"reqId":"MaWKdI7n8MhzZCM75Ijw","level":0,"time":"2018-10-18T12:36:59+00:00","remoteAddr":"127.0.0.1","user":"admin","app":"cron","method":"GET","url":"\/owncloud\/index.php\/cron","message":"Started background job of class : OCA\\Files\\BackgroundJob\\CleanupPersistentFileLocks with arguments : "}

Remove shareWithGroupMembersOnly helper and read from app config
directly.
@PVince81
Copy link
Contributor Author

all green 🎉

I'd appreciate some review before merging @DeepDiver1975 @jvillafanez @VicDeo

see "Description" in the original post and also the list of spaghettis I managed to untangle: #26608 (comment)

there are still some spaghettis to untangle which must be adressed separately as they are more involved

@PVince81 PVince81 modified the milestones: maybe some day, development Oct 18, 2018
@PVince81 PVince81 self-assigned this Oct 18, 2018
@DeepDiver1975 DeepDiver1975 merged commit a698db1 into master Oct 18, 2018
@DeepDiver1975 DeepDiver1975 deleted the remove-file-share-backends branch October 18, 2018 14:19
@PVince81 PVince81 mentioned this pull request Oct 18, 2018
14 tasks
@PVince81
Copy link
Contributor Author

raised #33219 for part 2 with remaining items

@VicDeo
Copy link
Member

VicDeo commented Oct 18, 2018

@PVince81 please note that \OCP\Share, \OCP\Share_Backend, \OCP\Share_Backend_Collection, \OCP\Share_Backend_File_Dependent should be marked as deprecated in stable10

@PVince81
Copy link
Contributor Author

@VicDeo thanks for the reminder, I'll submit a PR

@PVince81
Copy link
Contributor Author

deprecation PR for stable10: #33220

@phil-davis phil-davis mentioned this pull request Jul 8, 2019
10 tasks
@lock lock bot locked as resolved and limited conversation to collaborators Mar 17, 2020
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.

7 participants