Skip to content

Commit 5875b4c

Browse files
committed
fix: return JSON object instead of array for empty category restrictions
Empty PHP arrays serialize as JSON [] but the CategoryRestrictions TypeScript interface expects an object ({[rightId: string]: number[]}). Use stdClass to ensure {} is returned when there are no restrictions.
1 parent e5ad25a commit 5875b4c

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

phpmyfaq/src/phpMyFAQ/Controller/Administration/Api/GroupController.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,10 +145,13 @@ public function listCategoryRestrictions(Request $request): JsonResponse
145145
$groupId = (int) $request->attributes->get('groupId');
146146

147147
if (!$currentUser->perm instanceof MediumPermission) {
148-
return $this->json([], Response::HTTP_OK);
148+
return $this->json(new \stdClass(), Response::HTTP_OK);
149149
}
150150

151-
return $this->json($currentUser->perm->getAllCategoryRestrictions($groupId), Response::HTTP_OK);
151+
return $this->json(
152+
$currentUser->perm->getAllCategoryRestrictions($groupId) ?: new \stdClass(),
153+
Response::HTTP_OK,
154+
);
152155
}
153156

154157
/**

0 commit comments

Comments
 (0)