Skip to content

Commit

Permalink
Elements: add an API check to ensure we aren't trying to save a widge…
Browse files Browse the repository at this point in the history
…t with no elements. (#2390)

related to xibosignageltd/xibo-private#617
  • Loading branch information
dasgarner authored Feb 27, 2024
1 parent 8c71920 commit af51e7e
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions lib/Controller/Widget.php
Original file line number Diff line number Diff line change
Expand Up @@ -1658,6 +1658,14 @@ public function saveElements(Request $request, Response $response, $id)
throw new InvalidArgumentException(__('Invalid element JSON'), 'body');
}

// Validate that we have elements remaining.
if (count($elementJson) <= 0) {
throw new InvalidArgumentException(
__('At least one element is required for this Widget. Please delete it if you no longer need it.'),
'body',
);
}

// Parse the element JSON to see if we need to set `itemsPerPage`
$slots = [];
$uniqueSlots = 0;
Expand Down

0 comments on commit af51e7e

Please sign in to comment.