diff --git a/lib/Db/Row2.php b/lib/Db/Row2.php index 6b1b6adb0..cd7796bdd 100644 --- a/lib/Db/Row2.php +++ b/lib/Db/Row2.php @@ -107,6 +107,16 @@ public function insertOrUpdateCell(array $entry): string { return 'inserted'; } + /** + * @param int[] $columns + */ + public function filterDataByColumns(array $columns): array { + $this->data = array_values(array_filter($this->data, function ($entry) use ($columns) { + return in_array($entry['columnId'], $columns); + })); + return $this->data; + } + /** * @psalm-return TablesRow */ diff --git a/lib/Service/RowService.php b/lib/Service/RowService.php index 5d89cc652..e8d3ca416 100644 --- a/lib/Service/RowService.php +++ b/lib/Service/RowService.php @@ -397,7 +397,7 @@ public function updateSet( } } - return $this->row2Mapper->update($item, $columns); + return $this->filterRowResult($view ?? null, $this->row2Mapper->update($item, $columns)); } /** @@ -450,7 +450,7 @@ public function delete(int $id, ?int $viewId, string $userId): Row2 { } try { - return $this->row2Mapper->delete($item); + return $this->filterRowResult($view ?? null, $this->row2Mapper->delete($item)); } catch (Exception $e) { $this->logger->error($e->getMessage(), ['exception' => $e]); throw new InternalError(get_class($this) . ' - ' . __FUNCTION__ . ': '.$e->getMessage()); @@ -522,4 +522,14 @@ public function getViewRowsCount(View $view, string $userId): int { throw new PermissionError('no read access for counting to view id = '.$view->getId()); } } + + private function filterRowResult(?View $view, Row2 $row): Row2 { + if ($view === null) { + return $row; + } + + $row->filterDataByColumns($view->getColumnsArray()); + + return $row; + } }