Skip to content

Commit c44f619

Browse files
authored
Merge pull request #29 from kdambekalns/task/handle-missing-arguments
Gracefully handle missing action arguments
2 parents d2b7b4d + 2c5355b commit c44f619

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

Classes/Controller/CommentController.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,12 @@ protected function initializeAction()
5151
* @throws NodeException
5252
* @throws ConnectionException
5353
*/
54-
public function createAction(NodeInterface $postNode, NodeTemplate $newComment): string
54+
public function createAction(NodeInterface $postNode = null, NodeTemplate $newComment = null): string
5555
{
56+
if ($postNode === null || $newComment === null) {
57+
$this->throwStatus(400, 'Required parameters missing');
58+
}
59+
5660
# Workaround until we can validate node templates properly:
5761
if (strlen((string)$newComment->getProperty('author')) < 2) {
5862
$this->throwStatus(400, 'Your comment was NOT created - please specify your name.');

0 commit comments

Comments
 (0)