Fix unit tests breaking with v5

This commit is contained in:
Chris Lock 2023-07-03 00:00:33 +01:00
parent 628d4cb96e
commit d61b86fd3d

View File

@ -386,11 +386,8 @@ class GridFieldOrderableRows extends RequestHandler implements
$sortterm = $this->extraSortFields . ', ';
}
}
if ($list instanceof ArrayList) {
// Fix bug in 3.1.3+ where ArrayList doesn't account for quotes
$sortterm .= $this->getSortTable($list) . '.' . $this->getSortField();
} else {
$sortterm .= '"' . $this->getSortTable($list) . '"."' . $this->getSortField() . '"';
$sortterm .= '"' . $this->getSortField() . '"';
if ($list instanceof DataList) {
$classname = $list->dataClass();
@ -407,7 +404,6 @@ class GridFieldOrderableRows extends RequestHandler implements
$sortterm .= ($sortterm ? ', ' : '') . $defaultSort;
}
}
}
return $list->sort($sortterm);
}
@ -468,10 +464,10 @@ class GridFieldOrderableRows extends RequestHandler implements
protected function getSortedIDs($data)
{
if (empty($data['GridFieldEditableColumns'])) {
return array();
return [];
}
$sortedIDs = array();
$sortedIDs = [];
foreach ($data['GridFieldEditableColumns'] as $id => $recordData) {
$sortValue = $recordData[$this->sortField];
$sortedIDs[$sortValue] = $id;
@ -582,7 +578,8 @@ class GridFieldOrderableRows extends RequestHandler implements
}
}
$list = $grid->getList();
$sortterm .= '"' . $this->getSortTable($list) . '"."' . $sortField . '"';
$sortterm .= '"' . $sortField . '"';
$items = $list->filter('ID', $sortedIDs)->sort($sortterm);
// Ensure that each provided ID corresponded to an actual object.