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.
This commit is contained in:
Vincent Petry 2016-10-13 10:53:04 +02:00 committed by Morris Jobke
parent 1c4a1b8807
commit f07c209cb9
No known key found for this signature in database
GPG Key ID: 9CE5ED29E7FCD38A
2 changed files with 24 additions and 2 deletions

View File

@ -122,4 +122,26 @@ class GroupEtagPropagationTest extends PropagationTestCase {
$this->assertAllUnchanged(); $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();
}
} }

View File

@ -1059,7 +1059,7 @@ class Share extends Constants {
if (isset($groupShare['file_target'])) { if (isset($groupShare['file_target'])) {
$shareTmp['fileTarget'] = $groupShare['file_target']; $shareTmp['fileTarget'] = $groupShare['file_target'];
} }
$listOfUnsharedItems = array_merge($listOfUnsharedItems, array($groupShare)); $listOfUnsharedItems = array_merge($listOfUnsharedItems, [$shareTmp]);
$itemUnshared = true; $itemUnshared = true;
} elseif (!$itemUnshared && isset($uniqueGroupShare)) { } elseif (!$itemUnshared && isset($uniqueGroupShare)) {
$query = \OC_DB::prepare('UPDATE `*PREFIX*share` SET `permissions` = ? WHERE `id` = ?'); $query = \OC_DB::prepare('UPDATE `*PREFIX*share` SET `permissions` = ? WHERE `id` = ?');
@ -1074,7 +1074,7 @@ class Share extends Constants {
if (isset($uniqueGroupShare['file_target'])) { if (isset($uniqueGroupShare['file_target'])) {
$shareTmp['fileTarget'] = $uniqueGroupShare['file_target']; $shareTmp['fileTarget'] = $uniqueGroupShare['file_target'];
} }
$listOfUnsharedItems = array_merge($listOfUnsharedItems, array($uniqueGroupShare)); $listOfUnsharedItems = array_merge($listOfUnsharedItems, [$shareTmp]);
$itemUnshared = true; $itemUnshared = true;
} }