Skip to content

Commit

Permalink
fix: ensure header is present in the array before decoding it
Browse files Browse the repository at this point in the history
  • Loading branch information
imorland committed Sep 28, 2023
1 parent 00b92bb commit 0e78111
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/Api/Controllers/CreateHeaderItemController.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,9 @@ protected function data(ServerRequestInterface $request, Document $document)
$actor = RequestUtil::getActor($request);
$data = Arr::get($request->getParsedBody(), 'data', []);

Arr::set($data, 'attributes.header', Header::decode(Arr::get($data, 'attributes.header')));
if (Arr::has($data, 'attributes.header')) {
Arr::set($data, 'attributes.header', Header::decode(Arr::get($data, 'attributes.header')));
}

$this->validator->assertValid($data);

Expand Down
4 changes: 3 additions & 1 deletion src/Api/Controllers/UpdateHeaderItemController.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,9 @@ protected function data(ServerRequestInterface $request, Document $document)
$id = Arr::get($request->getQueryParams(), 'id');
$data = $request->getParsedBody();

Arr::set($data, 'attributes.header', Header::decode(Arr::get($data, 'attributes.header')));
if (Arr::has($data, 'attributes.header')) {
Arr::set($data, 'attributes.header', Header::decode(Arr::get($data, 'attributes.header')));
}

$this->validator->assertValid($data);

Expand Down

0 comments on commit 0e78111

Please sign in to comment.