]> source.dussan.org Git - nextcloud-server.git/commitdiff
Fix JSON error when comment has no reactions 32288/head
authorJoas Schilling <coding@schilljs.com>
Fri, 6 May 2022 08:35:17 +0000 (10:35 +0200)
committerJoas Schilling <coding@schilljs.com>
Mon, 9 May 2022 07:53:49 +0000 (09:53 +0200)
Signed-off-by: Joas Schilling <coding@schilljs.com>
lib/private/Comments/Manager.php

index 3275658d555f08c15ef508e0802cc3dbcaa17695..4a06ac62f1e03b970f7412e3e6e4312a532cc7ca 100644 (file)
@@ -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;
        }