From 33c5c8a9d98e06ee2c7d1c166c54d32b6b79e8d0 Mon Sep 17 00:00:00 2001 From: iglocska Date: Thu, 29 Aug 2024 06:49:28 +0200 Subject: [PATCH 1/3] fix: [error messages] improved for empty/malformed request bodies - instead of failing on a validation level for empty data, fail immediately on CRUD component level - send a clear message to the user that the request was malformed / the proper media type headers were not set --- src/Controller/Component/CRUDComponent.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Controller/Component/CRUDComponent.php b/src/Controller/Component/CRUDComponent.php index 02e3acb..9660d58 100644 --- a/src/Controller/Component/CRUDComponent.php +++ b/src/Controller/Component/CRUDComponent.php @@ -15,8 +15,10 @@ use Cake\Database\Expression\QueryExpression; use Cake\Routing\Router; use Cake\Http\Exception\MethodNotAllowedException; use Cake\Http\Exception\NotFoundException; +use Cake\Http\Exception\BadRequestException; use Cake\Collection\Collection; use App\Utility\UI\IndexSetting; +use phpDocumentor\Reflection\DocBlock\Tags\InvalidTag; class CRUDComponent extends Component { @@ -703,6 +705,9 @@ class CRUDComponent extends Component private function __massageInput($params) { $input = $this->request->getData(); + if (empty($input)) { + throw new BadRequestException(__('Invalid request content. Please make sure that you pass the data to be handled in the body and that the proper Accept and Content-type headers are set. This could also be caused by invalid JSON data being passed.')); + } if (!empty($params['override'])) { foreach ($params['override'] as $field => $value) { $input[$field] = $value; From dc880b1b3995358114bc6e751456c413fdd41fb7 Mon Sep 17 00:00:00 2001 From: iglocska Date: Thu, 29 Aug 2024 06:50:34 +0200 Subject: [PATCH 2/3] fix: [VERSION] bump --- src/VERSION.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/VERSION.json b/src/VERSION.json index 3fd4db5..d14f978 100644 --- a/src/VERSION.json +++ b/src/VERSION.json @@ -1,4 +1,4 @@ { - "version": "1.23", + "version": "1.24", "application": "Cerebrate" } From de39176b6abb09c75dd64004a550960507a70f2f Mon Sep 17 00:00:00 2001 From: iglocska Date: Thu, 29 Aug 2024 07:13:42 +0200 Subject: [PATCH 3/3] new: [version] show the cerebrate version and link to the release notes --- src/Controller/AppController.php | 3 +++ templates/element/layouts/header/header-right.php | 3 +++ 2 files changed, 6 insertions(+) diff --git a/src/Controller/AppController.php b/src/Controller/AppController.php index 334f923..28df320 100644 --- a/src/Controller/AppController.php +++ b/src/Controller/AppController.php @@ -145,6 +145,9 @@ class AppController extends Controller } $this->ACL->checkAccess(); + $version = file_get_contents(ROOT . DS . 'src' . DS . 'VERSION.json'); + $version = json_decode($version, true)['version']; + $this->set('cerebrate_version', $version); if (!$this->ParamHandler->isRest()) { $this->set('ajax', $this->request->is('ajax')); $this->request->getParam('prefix'); diff --git a/templates/element/layouts/header/header-right.php b/templates/element/layouts/header/header-right.php index 92686c6..34a83d1 100644 --- a/templates/element/layouts/header/header-right.php +++ b/templates/element/layouts/header/header-right.php @@ -1,4 +1,7 @@
+
+ Cerebrate v +