Skip to content

Commit

Permalink
fixup! fix(comments): Reference ID column is now added on upgrade and…
Browse files Browse the repository at this point in the history
… therefore can be removed
  • Loading branch information
nickvergessen committed Dec 13, 2023
1 parent 09afaa2 commit be577c2
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 11 deletions.
21 changes: 17 additions & 4 deletions lib/private/Comments/Comment.php
Original file line number Diff line number Diff line change
Expand Up @@ -404,15 +404,28 @@ public function setReferenceId(?string $referenceId): IComment {
/**
* @inheritDoc
*/
public function getMetaData(): ?string {
return $this->data['metaData'];
public function getMetaData(): ?array {
if ($this->data['metaData'] === null) {
return null;
}

try {
$metaData = json_decode($this->data['metaData'], true, flags: JSON_THROW_ON_ERROR);
} catch (\JsonException $e) {
return null;
}
return is_array($metaData) ? $metaData : null;
}

/**
* @inheritDoc
*/
public function setMetaData(?string $metaData): IComment {
$this->data['metaData'] = $metaData;
public function setMetaData(?array $metaData): IComment {
if ($metaData === null) {
$this->data['metaData'] = null;
} else {
$this->data['metaData'] = json_encode($metaData, JSON_THROW_ON_ERROR);
}
return $this;
}

Expand Down
15 changes: 8 additions & 7 deletions lib/public/Comments/IComment.php
Original file line number Diff line number Diff line change
Expand Up @@ -280,22 +280,23 @@ public function getReferenceId(): ?string;
public function setReferenceId(?string $referenceId): IComment;

/**
* returns the meta data of the comment
* Returns the metadata of the comment
*
* @return string|null
* @return array|null
* @since 29.0.0
*/
public function getMetaData(): ?string;
public function getMetaData(): ?array;

/**
* Sets (overwrites) the meta data of the comment
* It is recommended to store the data as a json encoded array
* Sets (overwrites) the metadata of the comment
* Data as a json encoded array
*
* @param string|null $metaData
* @param array|null $metaData
* @return IComment
* @throws \JsonException When the metadata can not be converted to a json encoded string
* @since 29.0.0
*/
public function setMetaData(?string $metaData): IComment;
public function setMetaData(?array $metaData): IComment;

/**
* Returns the reactions array if exists
Expand Down

0 comments on commit be577c2

Please sign in to comment.