diff --git a/src/Traits/GenericActionsTrait.php b/src/Traits/GenericActionsTrait.php index 837a60d..de0057e 100644 --- a/src/Traits/GenericActionsTrait.php +++ b/src/Traits/GenericActionsTrait.php @@ -67,9 +67,12 @@ protected function loadFilteredChildren(Folder $folder): array $order = ['Trees.tree_left']; } + $sortAllowlist = $this->paginate['sortWhitelist'] ?? (array)$this->request->getQuery('sort'); + $this->paginate['sortWhitelist'] = array_merge($sortAllowlist, array_keys($order)); + $children = $this->Objects->loadRelatedObjects($folder['uname'], 'folders', 'children', $this->Filters->fromQuery()); - return $this->paginate($children, ['order' => $order])->toList(); + return $this->paginate($children->order([], true), ['order' => $order])->toList(); } /**