From c68e3466e22a255e81fc2290f38819b3f7eb8433 Mon Sep 17 00:00:00 2001 From: cgfhtw Date: Wed, 6 Mar 2024 09:59:19 +0100 Subject: [PATCH] FilterCmpt: return error when no db entries --- application/controllers/components/Filter.php | 9 ++++++++- application/libraries/FilterCmptLib.php | 11 +++++++++++ public/js/components/filter/Filter.js | 4 +++- 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/application/controllers/components/Filter.php b/application/controllers/components/Filter.php index bde7d7ed7..e7c44bb97 100644 --- a/application/controllers/components/Filter.php +++ b/application/controllers/components/Filter.php @@ -41,7 +41,14 @@ class Filter extends FHC_Controller */ public function getFilter() { - $this->outputJsonSuccess($this->filtercmptlib->getSession()); + $session = $this->filtercmptlib->getSession(); + if (is_object($session)) { + // If stdClass it is an retval object + if (isError($session)) + $this->output->set_status_header(REST_Controller::HTTP_INTERNAL_SERVER_ERROR); + $this->outputJson($session); + } else + $this->outputJsonSuccess($session); } /** diff --git a/application/libraries/FilterCmptLib.php b/application/libraries/FilterCmptLib.php index 8b13ae3e5..fac6aaf63 100644 --- a/application/libraries/FilterCmptLib.php +++ b/application/libraries/FilterCmptLib.php @@ -176,6 +176,12 @@ class FilterCmptLib // Read the all session for this filter component $session = $this->getSession(); + // Was there an error before? + if (is_object($session)) { + $this->_setSession(null); + $session = null; + } + // If session is NOT empty -> a filter was already loaded if ($session != null) { @@ -266,6 +272,11 @@ class FilterCmptLib ); } } + else + { + $this->_setSession(error('Entries in the DB missing!')); + return; + } } // NOTE: latest operations to be performed in the session to be shure that they are always present diff --git a/public/js/components/filter/Filter.js b/public/js/components/filter/Filter.js index bbee7f4c1..31ddd43ff 100644 --- a/public/js/components/filter/Filter.js +++ b/public/js/components/filter/Filter.js @@ -296,7 +296,9 @@ export const CoreFilterCmpt = { } else { - console.error(CoreRESTClient.getError(response)); + // NOTE(chris): this should never happen -> error should have been + // catched before by the Fetch component. + console.error(response.retval); } }, /**