Skip to content

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

Merged
blizzz merged 4 commits into
masterfrom
fix-addressbook-deletion
Feb 15, 2017
Merged

Address book data lost when any user receiving a share is deleted#3473
blizzz merged 4 commits into
masterfrom
fix-addressbook-deletion

Conversation

@skjnldsv

@skjnldsvskjnldsv commented Feb 14, 2017

Copy link
Copy Markdown
Member

Fixnextcloud/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) <skjnldsv@protonmail.com>
Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
@skjnldsvskjnldsv added 3. to review Waiting for reviews and removed 2. developing Work in progress labels Feb 14, 2017
@jancborchardt

Copy link
Copy Markdown
Member

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

Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
@nickvergessen

Copy link
Copy Markdown
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
Copy Markdown
Member

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

@skjnldsv

Copy link
Copy Markdown
MemberAuthor

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

@skjnldsv

Copy link
Copy Markdown
MemberAuthor

Test fail unrelated. Restarted it.

schiessle
schiessle previously requested changes Feb 14, 2017
return array_values($addressBooks);
}

function getUsersOwnAddressBooks($principalUri) {

Copy link
Copy Markdown
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
Copy Markdown
MemberAuthor

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
Copy Markdown
MemberAuthor

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
Copy Markdown
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) <skjnldsv@protonmail.com>
@codecov-io

codecov-io commented Feb 14, 2017

Copy link
Copy Markdown

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 FilesCoverage ΔComplexity Δ
apps/dav/lib/HookManager.php55.76% <100%> (ø)15 <ø> (ø)
apps/dav/lib/CardDAV/CardDavBackend.php83.66% <100%> (+0.76%)84 <3> (+3)
lib/private/legacy/template.php43.19% <ø> (-1.84%)59% <ø> (+23%)
lib/private/Files/Storage/Common.php73.73% <ø> (-1.69%)200% <ø> (+70%)
core/js/shareconfigmodel.js76.66% <ø> (-1.6%)0% <ø> (ø)
lib/private/Files/Cache/Propagator.php94.93% <ø> (-1.27%)16% <ø> (ø)
settings/templates/users/part.userlist.php0% <ø> (ø)0% <ø> (ø)
settings/templates/personal.php0% <ø> (ø)0% <ø> (ø)
settings/users.php0% <ø> (ø)0% <ø> (ø)
config/config.sample.php0% <ø> (ø)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
Copy Markdown
Member

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

@blizzz
blizzz deleted the fix-addressbook-deletion branch February 15, 2017 10:34
@blizzz

Copy link
Copy Markdown
Member

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

@skjnldsv

Copy link
Copy Markdown
MemberAuthor

Of course!

@MorrisJobke

Copy link
Copy Markdown
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
Copy Markdown
Member

I would keep ours, theirs looks incomplete to me.

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants

@skjnldsv@jancborchardt@nickvergessen@tcitworld@schiessle@codecov-io@blizzz@MorrisJobke