diff options
author | Vincent Petry <pvince81@owncloud.com> | 2016-10-13 10:53:04 +0200 |
---|---|---|
committer | Morris Jobke <hey@morrisjobke.de> | 2016-10-20 16:09:08 +0200 |
commit | d4976e55544ddab17713e2f3aa4f5f5f5eb9986f (patch) | |
tree | 66c28164ef9b97524bccb56064de779be7a37e22 | |
parent | 5d7e9bb8fcbcd9a03cf0723c5258b41487850f7d (diff) | |
download | nextcloud-server-d4976e55544ddab17713e2f3aa4f5f5f5eb9986f.tar.gz nextcloud-server-d4976e55544ddab17713e2f3aa4f5f5f5eb9986f.zip |
Fix post_unshareFromSelf hook parameter format
When unsharing from self in a group share situation, the share items
passed to the post_unshareFromSelf hook were using the wrong format in
which the attribute names (ex: "share_type") have non camel-case format.
This fix makes sure that in group sharing case we use the correct
format. It looks like the code was already producing it but in
array_merge it was not using it and adding the unprocessed one.
-rw-r--r-- | apps/files_sharing/tests/GroupEtagPropagationTest.php | 22 | ||||
-rw-r--r-- | lib/private/Share/Share.php | 4 |
2 files changed, 24 insertions, 2 deletions
diff --git a/apps/files_sharing/tests/GroupEtagPropagationTest.php b/apps/files_sharing/tests/GroupEtagPropagationTest.php index eeb3c06bc59..e339983b404 100644 --- a/apps/files_sharing/tests/GroupEtagPropagationTest.php +++ b/apps/files_sharing/tests/GroupEtagPropagationTest.php @@ -122,4 +122,26 @@ class GroupEtagPropagationTest extends PropagationTestCase { $this->assertAllUnchanged(); } + + public function testRecipientUnsharesFromSelf() { + $this->loginAsUser(self::TEST_FILES_SHARING_API_USER2); + $this->assertTrue( + $this->rootView->unlink('/' . self::TEST_FILES_SHARING_API_USER2 . '/files/test') + ); + $this->assertEtagsChanged([self::TEST_FILES_SHARING_API_USER2]); + + $this->assertAllUnchanged(); + } + + public function testRecipientUnsharesFromSelfUniqueGroupShare() { + $this->loginAsUser(self::TEST_FILES_SHARING_API_USER2); + // rename to create an extra entry in the share table + $this->rootView->rename('/' . self::TEST_FILES_SHARING_API_USER2 . '/files/test', '/' . self::TEST_FILES_SHARING_API_USER2 . '/files/test_renamed'); + $this->assertTrue( + $this->rootView->unlink('/' . self::TEST_FILES_SHARING_API_USER2 . '/files/test_renamed') + ); + $this->assertEtagsChanged([self::TEST_FILES_SHARING_API_USER2]); + + $this->assertAllUnchanged(); + } } diff --git a/lib/private/Share/Share.php b/lib/private/Share/Share.php index 9210dfd1fd1..33801cd6347 100644 --- a/lib/private/Share/Share.php +++ b/lib/private/Share/Share.php @@ -1059,7 +1059,7 @@ class Share extends Constants { if (isset($groupShare['file_target'])) { $shareTmp['fileTarget'] = $groupShare['file_target']; } - $listOfUnsharedItems = array_merge($listOfUnsharedItems, array($groupShare)); + $listOfUnsharedItems = array_merge($listOfUnsharedItems, [$shareTmp]); $itemUnshared = true; } elseif (!$itemUnshared && isset($uniqueGroupShare)) { $query = \OC_DB::prepare('UPDATE `*PREFIX*share` SET `permissions` = ? WHERE `id` = ?'); @@ -1074,7 +1074,7 @@ class Share extends Constants { if (isset($uniqueGroupShare['file_target'])) { $shareTmp['fileTarget'] = $uniqueGroupShare['file_target']; } - $listOfUnsharedItems = array_merge($listOfUnsharedItems, array($uniqueGroupShare)); + $listOfUnsharedItems = array_merge($listOfUnsharedItems, [$shareTmp]); $itemUnshared = true; } |