From 36beef56028c07c07c4b3732eaa98e632f15f254 Mon Sep 17 00:00:00 2001 From: Arthur Schiwon Date: Fri, 12 Jul 2024 17:56:14 +0200 Subject: [PATCH] fixup! fix(View): column might be saved as null --- lib/Db/Row2Mapper.php | 6 ------ lib/Db/View.php | 12 +++++++++++- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/lib/Db/Row2Mapper.php b/lib/Db/Row2Mapper.php index e48bd2771..06deb17cf 100644 --- a/lib/Db/Row2Mapper.php +++ b/lib/Db/Row2Mapper.php @@ -271,12 +271,6 @@ private function getFilterGroups(IQueryBuilder &$qb, array $filters): array { private function getFilter(IQueryBuilder &$qb, array $filterGroup): array { $filterExpressions = []; foreach ($filterGroup as $filter) { - if ($filter['columnId'] === null) { - // a filter(group) was stored with a not-selected column. Skip, - // otherwise it breaks impressively. - continue; - } - $columnId = $filter['columnId']; // Fail if the filter is for a column that is not in the list and no meta column if (!isset($this->columns[$columnId]) && !isset($this->allColumns[$columnId]) && $columnId > 0) { diff --git a/lib/Db/View.php b/lib/Db/View.php index e3dc83e66..4210dcaf7 100644 --- a/lib/Db/View.php +++ b/lib/Db/View.php @@ -95,7 +95,17 @@ public function getSortArray(): array { * @return list> */ public function getFilterArray():array { - return $this->getArray($this->getFilter()); + $filters = $this->getArray($this->getFilter()); + // a filter(group) was stored with a not-selected column - it may break impressively. + // filter them out now until we have a permanent fix + foreach ($filters as &$filterGroups) { + $filterGroups = array_filter($filterGroups, function (array $item) { + return $item['columnId'] !== null; + }); + } + return array_filter($filters, function (array $item) { + return !empty($item); + }); } private function getArray(?string $json): array {