Skip to content

Commit

Permalink
Merge pull request #250 from sminnee/form-head-request-throws-500
Browse files Browse the repository at this point in the history
Return 404 rather than 500 on bad actions in requesthandler
  • Loading branch information
chillu committed Mar 22, 2012
2 parents 673500c + 1d5065f commit 0ad6fe7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
5 changes: 4 additions & 1 deletion control/RequestHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -162,12 +162,15 @@ function handleRequest(SS_HTTPRequest $request, DataModel $model) {
}

try {
if(!$this->hasMethod($action)) {
return $this->httpError(404, "Action '$action' isn't available on class " . get_class($this) . ".");
}
$result = $this->$action($request);
} catch(SS_HTTPResponse_Exception $responseException) {
$result = $responseException->getResponse();
}
} else {
return $this->httpError(403, "Action '$action' isn't allowed on class $this->class");
return $this->httpError(403, "Action '$action' isn't allowed on class " . get_class($this) . ".");
}

if($result instanceof SS_HTTPResponse && $result->isError()) {
Expand Down
1 change: 0 additions & 1 deletion forms/Form.php
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,6 @@ public function __construct($controller, $name, FieldList $fields, FieldList $ac

static $url_handlers = array(
'field/$FieldName!' => 'handleField',
'$Action!' => 'handleAction',
'POST ' => 'httpSubmission',
'GET ' => 'httpSubmission',
'HEAD ' => 'httpSubmission',
Expand Down

0 comments on commit 0ad6fe7

Please sign in to comment.