Skip to content

Commit

Permalink
Make missing document return 404 instead of server error
Browse files Browse the repository at this point in the history
  • Loading branch information
Harry Green committed Mar 29, 2021
1 parent 110b922 commit 1cca811
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions src/Control/DMSDocumentController.php
Original file line number Diff line number Diff line change
Expand Up @@ -170,17 +170,13 @@ protected function getDocumentFromID($request)
* Get a document's ID from a "friendly" URL slug containing a numeric ID and slugged title
*
* @param string $slug
* @return int
* @throws InvalidArgumentException if an invalid format is provided
* @return int|false
*/
protected function getDocumentIdFromSlug($slug)
{
$parts = (array) sscanf($slug, '%d-%s');
$id = array_shift($parts);
if (is_numeric($id)) {
return (int) $id;
}
throw new InvalidArgumentException($slug . ' is not a valid DMSDocument URL');
return is_numeric($id) ? (int) $id : false;
}

/**
Expand Down

0 comments on commit 1cca811

Please sign in to comment.