From: Julien Veyssier Date: Mon, 31 Aug 2020 15:44:30 +0000 (+0200) Subject: refs #22468 fix empty php array becoming an array instead of an object in UI X-Git-Tag: v20.0.0beta4~58^2 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=refs%2Fpull%2F22531%2Fhead;p=nextcloud-server.git refs #22468 fix empty php array becoming an array instead of an object in UI Signed-off-by: Julien Veyssier --- diff --git a/apps/dashboard/lib/Controller/DashboardController.php b/apps/dashboard/lib/Controller/DashboardController.php index c9fd96fcb6f..57717b26698 100644 --- a/apps/dashboard/lib/Controller/DashboardController.php +++ b/apps/dashboard/lib/Controller/DashboardController.php @@ -103,8 +103,12 @@ class DashboardController extends Controller { 'url' => $widget->getUrl() ]; }, $this->dashboardManager->getWidgets()); - $configStatuses = $this->config->getUserValue($this->userId, 'dashboard', 'statuses', '{}'); + $configStatuses = $this->config->getUserValue($this->userId, 'dashboard', 'statuses', ''); $statuses = json_decode($configStatuses, true); + // We avoid getting an empty array as it will not produce an object in UI's JS + // It does not matter if some statuses are missing from the array, missing ones are considered enabled + $statuses = ($statuses && count($statuses) > 0) ? $statuses : ['weather' => true]; + $this->inititalStateService->provideInitialState('dashboard', 'panels', $widgets); $this->inititalStateService->provideInitialState('dashboard', 'statuses', $statuses); $this->inititalStateService->provideInitialState('dashboard', 'layout', $userLayout);