From 4723463044fa22acda0c9cb4356b1b759e45bb68 Mon Sep 17 00:00:00 2001 From: Sukhwinder Dhillon Date: Mon, 28 Aug 2023 09:16:38 +0200 Subject: [PATCH] Controller: Return an empty array if no values are defined for the `columns` param --- library/Icingadb/Web/Controller.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/library/Icingadb/Web/Controller.php b/library/Icingadb/Web/Controller.php index 49bd1c799..c8765ef7d 100644 --- a/library/Icingadb/Web/Controller.php +++ b/library/Icingadb/Web/Controller.php @@ -87,12 +87,13 @@ public function createColumnControl(Query $query, ViewModeSwitcher $viewModeSwit { // All of that is essentially what `ColumnControl::apply()` should do $viewMode = $this->getRequest()->getUrl()->getParam($viewModeSwitcher->getViewModeParam()); - $columnsDef = $this->params->shift('columns'); - if (! $columnsDef) { - if ($viewMode === 'tabular') { - $this->httpBadRequest('Missing parameter "columns"'); - } + if ($viewMode === 'tabular' && ! $this->params->has('columns')) { + $this->httpBadRequest('Missing parameter "columns"'); + } + + $columnsDef = $this->params->shift('columns'); + if (empty($columnsDef) || $columnsDef === '1') { return []; }