MVC - ApiControllerBase : safeguard multi_sort in searchRecordsetBase() when non-existing column is passed

ref : https://forum.opnsense.org/index.php?topic=28043.msg136169#msg136169
This commit is contained in:
Ad Schellevis 2022-04-21 19:06:02 +02:00
parent 26f72adaf6
commit 4ec9ea3d1a

View File

@ -84,10 +84,14 @@ class ApiControllerBase extends ControllerRoot
$keys = array_keys($this->request->getPost('sort'));
$order = $this->request->getPost('sort')[$keys[0]];
$keys = array_column($formatted, $keys[0]);
array_multisort($keys, $order == 'asc' ? SORT_ASC : SORT_DESC, $sort_flags, $formatted);
if (!empty($keys)) {
array_multisort($keys, $order == 'asc' ? SORT_ASC : SORT_DESC, $sort_flags, $formatted);
}
} elseif (!empty($defaultSort)) {
$keys = array_column($formatted, $defaultSort);
array_multisort($keys, SORT_ASC, $sort_flags, $formatted);
if (!empty($keys)) {
array_multisort($keys, SORT_ASC, $sort_flags, $formatted);
}
}
return [