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

Address book data lost when any user receiving a share is deleted #3473

Merged
merged 4 commits into from
Feb 15, 2017

Conversation

skjnldsv
Copy link
Member

@skjnldsv skjnldsv commented Feb 14, 2017

Fix nextcloud/contacts#64
Reference: #1545

@nextcloud/contacts @cemrich @jeweloper @nickallevato

Steps to reproduce

  1. Create user1 with an address book shared to group1
  2. Create user2 of group1 to view the address book
  3. Delete user2

Expected behaviour

User2 gets deleted but the shared address book of user1 remains intact.

Actual behaviour

The shared address book of user1 gets deleted. The tables oc_addressbooks and oc_cards are wiped of all information regarding this address book. If the given address book is the only one of user1, the "infinite loading bug" as described in #58 appears.

Server configuration

Operating system: ?

Web server: ?

Database: mysql 5.1.73

PHP version: 7.0.13

Nextcloud version: 11.0.0 (stable)

Contacts version: 1.5.2

Updated from an older Nextcloud or fresh install: fresh install

Signing status:

No errors have been found.

Are you using an external user-backend, if yes which one: no

Client configuration

Browser: Firefox 50.0.2 and Chrome 54.0.2840.99 m (64-bit)

Operating system: Windows 10

Signed-off-by: John Molakvoæ (skjnldsv) <[email protected]>
Signed-off-by: John Molakvoæ (skjnldsv) <[email protected]>
@skjnldsv skjnldsv added 3. to review Waiting for reviews and removed 2. developing Work in progress labels Feb 14, 2017
@jancborchardt
Copy link
Member

Cc @nickvergessen @MorrisJobke @schiessle @blizzz for testing too since this is high impact :O

Signed-off-by: John Molakvoæ (skjnldsv) <[email protected]>
@nickvergessen
Copy link
Member

Ouch, sounds valid and the diff makes sense. Is it the same for calendars? Or how is the situation handled there?

@tcitworld
Copy link
Member

Calendar backend already has getUsersOwnCalendars which is properly used. Good catch.

@skjnldsv
Copy link
Member Author

Yeah, I based my works on @tcitworld's previous pr :)
We need to backport too 😞

@skjnldsv
Copy link
Member Author

Test fail unrelated. Restarted it.

@@ -195,6 +195,33 @@ function getAddressBooksForUser($principalUri) {
return array_values($addressBooks);
}

function getUsersOwnAddressBooks($principalUri) {
Copy link
Member

Choose a reason for hiding this comment

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

please put a explicit "public" in front of the function. Seems like this file has a wired mixture here but I would like to keep it consistent with the other code.

Maybe it would also make sense to write a unit test for it?

Copy link
Member Author

Choose a reason for hiding this comment

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

There is already some unit tests for it in testDeleteCalendar. Is it enough?

Copy link
Member Author

Choose a reason for hiding this comment

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

And if you want bigger test, i'm sorry but I don't have the necessary knowledge to do correct ones here.
I'm too unfamiliar with the whole phpunit section here and don't have enough time to read to assimilate it :(

@schiessle
Copy link
Member

Tested it.... Beside the small stuff I mentioned above the code looks good and it works as expected!

Signed-off-by: John Molakvoæ (skjnldsv) <[email protected]>
@codecov-io
Copy link

codecov-io commented Feb 14, 2017

Codecov Report

Merging #3473 into master will increase coverage by <.01%.
The diff coverage is 100%.

@@             Coverage Diff              @@
##             master    #3473      +/-   ##
============================================
+ Coverage     54.16%   54.16%   +<.01%     
- Complexity    21007    21185     +178     
============================================
  Files          1306     1306              
  Lines         80206    81105     +899     
  Branches       1255     1300      +45     
============================================
+ Hits          43441    43932     +491     
- Misses        36765    37173     +408
Impacted Files Coverage Δ Complexity Δ
apps/dav/lib/HookManager.php 55.76% <100%> (ø) 15 <ø> (ø)
apps/dav/lib/CardDAV/CardDavBackend.php 83.66% <100%> (+0.76%) 84 <3> (+3)
lib/private/legacy/template.php 43.19% <ø> (-1.84%) 59% <ø> (+23%)
lib/private/Files/Storage/Common.php 73.73% <ø> (-1.69%) 200% <ø> (+70%)
core/js/shareconfigmodel.js 76.66% <ø> (-1.6%) 0% <ø> (ø)
lib/private/Files/Cache/Propagator.php 94.93% <ø> (-1.27%) 16% <ø> (ø)
settings/templates/users/part.userlist.php 0% <ø> (ø) 0% <ø> (ø)
settings/templates/personal.php 0% <ø> (ø) 0% <ø> (ø)
settings/users.php 0% <ø> (ø) 0% <ø> (ø)
config/config.sample.php 0% <ø> (ø) 0% <ø> (ø)
... and 8 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 7113af3...7e9411b. Read the comment docs.

@nickvergessen
Copy link
Member

Please also make a PR against stable11 so we can fix it before the release on friday, thanks!

@blizzz blizzz merged commit 44186ca into master Feb 15, 2017
@blizzz blizzz deleted the fix-addressbook-deletion branch February 15, 2017 10:34
@blizzz
Copy link
Member

blizzz commented Feb 15, 2017

@skjnldsv great stuff, thx! Could you also create a backport PR against stable11?

@skjnldsv
Copy link
Member Author

Of course!

@MorrisJobke
Copy link
Member

@skjnldsv @blizzz @schiessle @nickvergessen @tcitworld Would it make sense to adopt the stuff from upstream: owncloud/core#27169 ... it looks similar but seems to go a different way. Which code is better? Or should we just keep it how it is?

@nickvergessen
Copy link
Member

I would keep ours, theirs looks incomplete to me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants