diff options
author | Vincent Petry <pvince81@owncloud.com> | 2016-07-22 10:08:05 +0200 |
---|---|---|
committer | Roeland Jago Douma <roeland@famdouma.nl> | 2016-08-03 10:16:28 +0200 |
commit | 0c6352e0955cb2b47496655f275ee06db2298a52 (patch) | |
tree | 67418d723a9a04781e1a9fc44393f7605c7e9660 /lib/private/Repair | |
parent | 0c7c9a3b950ce4261a6fc76cb23f97c3673a03e4 (diff) | |
download | nextcloud-server-0c6352e0955cb2b47496655f275ee06db2298a52.tar.gz nextcloud-server-0c6352e0955cb2b47496655f275ee06db2298a52.zip |
Fix RepairUnmergedShares to not skip valid repair cases
The repair step was a bit overeager to skip repairing so it missed the
case where a group share exists without subshares but with an
additional direct user share.
Diffstat (limited to 'lib/private/Repair')
-rw-r--r-- | lib/private/Repair/RepairUnmergedShares.php | 27 |
1 files changed, 16 insertions, 11 deletions
diff --git a/lib/private/Repair/RepairUnmergedShares.php b/lib/private/Repair/RepairUnmergedShares.php index 15a4762da79..353877bb873 100644 --- a/lib/private/Repair/RepairUnmergedShares.php +++ b/lib/private/Repair/RepairUnmergedShares.php @@ -158,6 +158,10 @@ class RepairUnmergedShares implements IRepairStep { * @return boolean false if the share was not repaired, true if it was */ private function fixThisShare($groupShares, $subShares) { + if (empty($subShares)) { + return false; + } + $groupSharesById = []; foreach ($groupShares as $groupShare) { $groupSharesById[$groupShare['id']] = $groupShare; @@ -253,27 +257,28 @@ class RepairUnmergedShares implements IRepairStep { return; } + // get all subshares grouped by item source $subSharesByItemSource = $this->getSharesWithUser(DefaultShareProvider::SHARE_TYPE_USERGROUP, [$user->getUID()]); - if (empty($subSharesByItemSource)) { - // nothing to repair for this user + + // because sometimes one wants to give the user more permissions than the group share + $userSharesByItemSource = $this->getSharesWithUser(Constants::SHARE_TYPE_USER, [$user->getUID()]); + + if (empty($subSharesByItemSource) && empty($userSharesByItemSource)) { + // nothing to repair for this user, no need to do extra queries return; } $groupSharesByItemSource = $this->getSharesWithUser(Constants::SHARE_TYPE_GROUP, $groups); - if (empty($groupSharesByItemSource)) { - // shouldn't happen, those invalid shares must be cleant already by RepairInvalidShares + if (empty($groupSharesByItemSource) && empty($userSharesByItemSource)) { + // nothing to repair for this user return; } - // because sometimes one wants to give the user more permissions than the group share - $userSharesByItemSource = $this->getSharesWithUser(Constants::SHARE_TYPE_USER, [$user->getUID()]); - foreach ($groupSharesByItemSource as $itemSource => $groupShares) { - if (!isset($subSharesByItemSource[$itemSource])) { - // no subshares for this item source, skip it - continue; + $subShares = []; + if (isset($subSharesByItemSource[$itemSource])) { + $subShares = $subSharesByItemSource[$itemSource]; } - $subShares = $subSharesByItemSource[$itemSource]; if (isset($userSharesByItemSource[$itemSource])) { // add it to the subshares to get a similar treatment |