From caf2b989214e4823f54d68ba943825733a8fd82d Mon Sep 17 00:00:00 2001 From: trendschau Date: Fri, 5 Jan 2024 19:49:44 +0100 Subject: [PATCH] v2.1.0 fix download response if no file found --- .../typemill/Controllers/ControllerWebDownload.php | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/system/typemill/Controllers/ControllerWebDownload.php b/system/typemill/Controllers/ControllerWebDownload.php index 4ed8a84..a81d75a 100644 --- a/system/typemill/Controllers/ControllerWebDownload.php +++ b/system/typemill/Controllers/ControllerWebDownload.php @@ -2,18 +2,20 @@ namespace Typemill\Controllers; +use Psr\Http\Message\ServerRequestInterface as Request; +use Psr\Http\Message\ResponseInterface as Response; use Typemill\Models\StorageWrapper; use Typemill\Static\Translations; class ControllerWebDownload extends Controller { - public function download($request, $response, $args) + public function download(Request $request, Response $response, $args) { $filename = isset($args['params']) ? $args['params'] : false; if(!$filename) { - $response->getBody()->write(Translations::translate('the requested file does not exist.'))->withStatus(404); - return $response; + $response->getBody()->write(Translations::translate('the requested file does not exist.')); + return $response->withStatus(404); } $storage = new StorageWrapper('\Typemill\Models\Storage'); @@ -26,8 +28,8 @@ class ControllerWebDownload extends Controller $allowedFiletypes = []; if(!$this->validate($filepath, $filename, $allowedFiletypes)) { - $response->getBody()->write(Translations::translate('the requested filetype does not exist.'))->withStatus(404); - return $response; + $response->getBody()->write(Translations::translate('the requested filetype does not exist.')); + return $response->withStatus(404); } if($restrictions && isset($restrictions[$filefolder . $filename]))