From 1cca811c5f585e44c9472da49a976068ff818113 Mon Sep 17 00:00:00 2001 From: Harry Green Date: Mon, 29 Mar 2021 15:29:17 +1300 Subject: [PATCH] Make missing document return 404 instead of server error --- src/Control/DMSDocumentController.php | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/Control/DMSDocumentController.php b/src/Control/DMSDocumentController.php index 0299f6c0..9f923080 100644 --- a/src/Control/DMSDocumentController.php +++ b/src/Control/DMSDocumentController.php @@ -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; } /**