From 29170a28f97a2d459bec6d2cf3da69feb614953f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maur=C3=ADcio=20Meneghini=20Fauth?= Date: Thu, 5 May 2022 22:33:58 -0300 Subject: [PATCH] Remove UI props if cached fields count differs from actual MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Fixes #17428 - Fixes #17498 Signed-off-by: MaurĂ­cio Meneghini Fauth --- libraries/classes/Display/Results.php | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/libraries/classes/Display/Results.php b/libraries/classes/Display/Results.php index f46fd3ab0a..1092aab401 100644 --- a/libraries/classes/Display/Results.php +++ b/libraries/classes/Display/Results.php @@ -3186,19 +3186,29 @@ class Results if ($this->isSelect($analyzed_sql_results)) { $pmatable = new Table($this->properties['table'], $this->properties['db']); $col_order = $pmatable->getUiProp(Table::PROP_COLUMN_ORDER); + $fields_cnt = $this->properties['fields_cnt']; /* Validate the value */ - if ($col_order !== false) { - $fields_cnt = $this->properties['fields_cnt']; + if (is_array($col_order)) { foreach ($col_order as $value) { if ($value < $fields_cnt) { continue; } $pmatable->removeUiProp(Table::PROP_COLUMN_ORDER); - $fields_cnt = false; + break; + } + + if ($fields_cnt !== count($col_order)) { + $pmatable->removeUiProp(Table::PROP_COLUMN_ORDER); + $col_order = false; } } + $col_visib = $pmatable->getUiProp(Table::PROP_COLUMN_VISIB); + if (is_array($col_visib) && $fields_cnt !== count($col_visib)) { + $pmatable->removeUiProp(Table::PROP_COLUMN_VISIB); + $col_visib = false; + } } else { $col_order = false; $col_visib = false;