aboutsummaryrefslogtreecommitdiffstats
path: root/lib/private/Comments
diff options
context:
space:
mode:
authorJoas Schilling <coding@schilljs.com>2022-05-06 10:35:17 +0200
committerJoas Schilling <coding@schilljs.com>2022-05-09 09:53:49 +0200
commit4e0595fb0f8413832865975748898445bc4117c4 (patch)
tree0e78faf44c3bbfab3ff18adf9ad8c1d4459fab63 /lib/private/Comments
parent4f55ba2a8895995649306911e3efa92904906836 (diff)
downloadnextcloud-server-4e0595fb0f8413832865975748898445bc4117c4.tar.gz
nextcloud-server-4e0595fb0f8413832865975748898445bc4117c4.zip
Fix JSON error when comment has no reactions
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'lib/private/Comments')
-rw-r--r--lib/private/Comments/Manager.php28
1 files changed, 17 insertions, 11 deletions
diff --git a/lib/private/Comments/Manager.php b/lib/private/Comments/Manager.php
index 3275658d555..4a06ac62f1e 100644
--- a/lib/private/Comments/Manager.php
+++ b/lib/private/Comments/Manager.php
@@ -110,18 +110,24 @@ class Manager implements ICommentsManager {
$data['children_count'] = (int)$data['children_count'];
$data['reference_id'] = $data['reference_id'] ?? null;
if ($this->supportReactions()) {
- $list = json_decode($data['reactions'], true);
- // Ordering does not work on the database with group concat and Oracle,
- // So we simply sort on the output.
- if (is_array($list)) {
- uasort($list, static function ($a, $b) {
- if ($a === $b) {
- return 0;
- }
- return ($a > $b) ? -1 : 1;
- });
+ if ($data['reactions'] !== null) {
+ $list = json_decode($data['reactions'], true);
+ // Ordering does not work on the database with group concat and Oracle,
+ // So we simply sort on the output.
+ if (is_array($list)) {
+ uasort($list, static function ($a, $b) {
+ if ($a === $b) {
+ return 0;
+ }
+ return ($a > $b) ? -1 : 1;
+ });
+ $data['reactions'] = $list;
+ } else {
+ $data['reactions'] = [];
+ }
+ } else {
+ $data['reactions'] = [];
}
- $data['reactions'] = $list;
}
return $data;
}