diff options
author | Vincent Petry <pvince81@owncloud.com> | 2016-07-22 11:08:05 +0300 |
---|---|---|
committer | Thomas Müller <thomas.mueller@tmit.eu> | 2016-08-13 18:10:13 +0300 |
commit | 2d463d3991da9e7c26156dd42cff46a330669e20 (patch) | |
tree | a9db593e19ac045db379a28dd16c728fb0dffa51 /lib | |
parent | b194b9f408851c7fd52449c69ea1bb06d126987f (diff) |
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')
-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 5027dddce92..77bb03ad462 100644 --- a/lib/private/repair/repairunmergedshares.php +++ b/lib/private/repair/repairunmergedshares.php @@ -158,6 +158,10 @@ class RepairUnmergedShares extends BasicEmitter implements \OC\RepairStep { * @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,28 +257,29 @@ class RepairUnmergedShares extends BasicEmitter implements \OC\RepairStep { 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()]); - $fixed = 0; 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 |