Remove UI props if cached fields count differs from actual

- Fixes #17428
- Fixes #17498

Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
This commit is contained in:
Maurício Meneghini Fauth 2022-05-05 22:33:58 -03:00
parent 2d475d6680
commit 29170a28f9
No known key found for this signature in database
GPG Key ID: 6A16FD38AFC89CC8

View File

@ -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;