Skip to content

Commit 41a39c4

Browse files
authored
Merge pull request #1733 from nextcloud/backport/1731/stable29
[stable29] fix(ShareWrapperRequest): Save share attributes on creation
2 parents 23c538a + bab79d3 commit 41a39c4

2 files changed

Lines changed: 6 additions & 3 deletions

File tree

lib/Db/ShareWrapperRequest.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,8 @@ class ShareWrapperRequest extends ShareWrapperRequestBuilder {
6060
*/
6161
public function save(IShare $share, int $parentId = 0): int {
6262
$qb = $this->getShareInsertSql();
63-
$qb->setValue('share_type', $qb->createNamedParameter($share->getShareType()))
63+
$qb->setValue('attributes', $qb->createNamedParameter($this->formatShareAttributes($share->getAttributes())))
64+
->setValue('share_type', $qb->createNamedParameter($share->getShareType()))
6465
->setValue('item_type', $qb->createNamedParameter($share->getNodeType()))
6566
->setValue('item_source', $qb->createNamedParameter($share->getNodeId()))
6667
->setValue('file_source', $qb->createNamedParameter($share->getNodeId()))
@@ -534,7 +535,7 @@ private function formatShareAttributes(?IAttributes $attributes): ?string {
534535
$compressedAttributes[] = [
535536
$attribute['scope'],
536537
$attribute['key'],
537-
$attribute['enabled']
538+
$attribute['value']
538539
];
539540
}
540541

lib/Model/ShareWrapper.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -498,6 +498,8 @@ public function import(array $data): IDeserializable {
498498
->setToken($this->get('token', $data))
499499
->setShareTime($shareTime);
500500

501+
$this->importAttributesFromDatabase($this->get('attributes', $data));
502+
501503
try {
502504
$this->setExpirationDate(new DateTime($this->get('expiration', $data)));
503505
} catch (\Exception $e) {
@@ -610,7 +612,7 @@ public function jsonSerialize(): array {
610612
'shareType' => $this->getShareType(),
611613
'providerId' => $this->getProviderId(),
612614
'permissions' => $this->getPermissions(),
613-
'attributes' => $this->getAttributes(),
615+
'attributes' => json_encode($this->getAttributes()->toArray()),
614616
'hideDownload' => $this->getHideDownload(),
615617
'itemType' => $this->getItemType(),
616618
'itemSource' => $this->getItemSource(),

0 commit comments

Comments
 (0)