Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoas Schilling <coding@schilljs.com>2022-05-06 11:35:17 +0300
committerJoas Schilling <coding@schilljs.com>2022-05-06 11:35:17 +0300
commit9104f8e180cf6c17ee805f5c274e0d5933414539 (patch)
tree9613c4b926221e63670eb1492fa53da9faa244a6
parent9c427172163931ca41e4408e74417fdb86a04190 (diff)
Fix JSON error when comment has no reactionstechdebt/noid/fix-json-error
Signed-off-by: Joas Schilling <coding@schilljs.com>
-rw-r--r--lib/private/Comments/Manager.php26
1 files changed, 15 insertions, 11 deletions
diff --git a/lib/private/Comments/Manager.php b/lib/private/Comments/Manager.php
index 3275658d555..9781e76f864 100644
--- a/lib/private/Comments/Manager.php
+++ b/lib/private/Comments/Manager.php
@@ -110,18 +110,22 @@ 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']) {
+ $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'] = [];
}
- $data['reactions'] = $list;
}
return $data;
}