Skip to content

Commit 200a469

Browse files
committed
fix: Fix FsActionmapper
Signed-off-by: Marcel Klehr <[email protected]>
1 parent 19f4aeb commit 200a469

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

lib/Db/FsActionMapper.php

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -138,14 +138,19 @@ public function count(string $className): int {
138138
* @throws MultipleObjectsReturnedException
139139
*/
140140
public function findByStorageIdAndRootId(string $className, int $storageId, int $rootId): Entity {
141-
if (!in_array('storage_id', $className::$columns, true) || !in_array('node_id', $className::$columns, true)) {
142-
throw new \Exception('entity does not have all required columns: storage_id, node_id');
141+
if (!in_array('storage_id', $className::$columns, true) || (!in_array('root_id', $className::$columns, true) && !in_array('node_id', $className::$columns, true))) {
142+
throw new \Exception('entity does not have all required columns: storage_id, node_id/root_id');
143143
}
144144
$qb = $this->db->getQueryBuilder();
145145
$qb->selectDistinct($className::$columns)
146146
->from($className::$tableName)
147-
->where($qb->expr()->eq('storage_id', $qb->createPositionalParameter($storageId, IQueryBuilder::PARAM_INT)))
148-
->andWhere($qb->expr()->eq('root_id', $qb->createPositionalParameter($rootId, IQueryBuilder::PARAM_INT)));
147+
->where($qb->expr()->eq('storage_id', $qb->createPositionalParameter($storageId, IQueryBuilder::PARAM_INT)));
148+
if (in_array('root_id', $className::$columns, true)) {
149+
$qb->andWhere($qb->expr()->eq('root_id', $qb->createPositionalParameter($rootId, IQueryBuilder::PARAM_INT)));
150+
}
151+
if (in_array('node_id', $className::$columns, true)) {
152+
$qb->andWhere($qb->expr()->eq('node_id', $qb->createPositionalParameter($rootId, IQueryBuilder::PARAM_INT)));
153+
}
149154
return $this->findItem($className, $qb);
150155
}
151156

0 commit comments

Comments
 (0)