mirror of
https://github.com/flarum/framework.git
synced 2025-02-24 02:46:25 +08:00
Fix Internal Server Error for blank API requests
Attempting to send an empty body to the create and update endpoints will result in Flarum outputting "Internal Server Error" as plain text, instead of failing gracefully with a json-ised validation exception. This commit adds an empty array as the third parameter to array_get, which sets the default value and thus allows Flarum to do its thing.
This commit is contained in:
parent
be643a1e4b
commit
fb8ad8fe9a
@ -44,7 +44,7 @@ class CreateTagController extends AbstractCreateController
|
||||
protected function data(ServerRequestInterface $request, Document $document)
|
||||
{
|
||||
return $this->bus->dispatch(
|
||||
new CreateTag($request->getAttribute('actor'), array_get($request->getParsedBody(), 'data'))
|
||||
new CreateTag($request->getAttribute('actor'), array_get($request->getParsedBody(), 'data', []))
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -45,7 +45,7 @@ class UpdateTagController extends AbstractResourceController
|
||||
{
|
||||
$id = array_get($request->getQueryParams(), 'id');
|
||||
$actor = $request->getAttribute('actor');
|
||||
$data = array_get($request->getParsedBody(), 'data');
|
||||
$data = array_get($request->getParsedBody(), 'data', []);
|
||||
|
||||
return $this->bus->dispatch(
|
||||
new EditTag($id, $actor, $data)
|
||||
|
Loading…
x
Reference in New Issue
Block a user