Skip to content

Commit

Permalink
fix(softUndeleteEntry): Only reset index of bookmarks if it is indeed…
Browse files Browse the repository at this point in the history
… soft-deleted

Signed-off-by: Marcel Klehr <[email protected]>
  • Loading branch information
marcelklehr committed Oct 9, 2024
1 parent 9efa644 commit 1ed4a56
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions lib/Db/TreeMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -542,20 +542,21 @@ public function softUndeleteEntry(string $type, int $id, ?int $folderId = null):
return;
}

// set entry as not deleted
// has to come last to not break findByAncestorFolder
$qb = $this->db->getQueryBuilder();
$qb
->update('bookmarks_tree')
->set('soft_deleted_at', $qb->createNamedParameter(null, IQueryBuilder::PARAM_DATE))
->where($qb->expr()->eq('id', $qb->createNamedParameter($id, IQueryBuilder::PARAM_INT)))
->andWhere($qb->expr()->eq('type', $qb->createNamedParameter($type, IQueryBuilder::PARAM_STR)));
if ($folderId !== null) {
$qb->set('index', $qb->createNamedParameter($this->countChildren($folderId)));
$qb->andWhere($qb->expr()->eq('parent_folder', $qb->createNamedParameter($folderId, IQueryBuilder::PARAM_INT)));
if ($this->isEntrySoftDeleted($type, $id, $folderId)) {
// set entry as not deleted
// has to come last to not break findByAncestorFolder
$qb = $this->db->getQueryBuilder();
$qb
->update('bookmarks_tree')
->set('soft_deleted_at', $qb->createNamedParameter(null, IQueryBuilder::PARAM_DATE))
->where($qb->expr()->eq('id', $qb->createNamedParameter($id, IQueryBuilder::PARAM_INT)))
->andWhere($qb->expr()->eq('type', $qb->createNamedParameter($type, IQueryBuilder::PARAM_STR)));
if ($folderId !== null) {
$qb->set('index', $qb->createNamedParameter($this->countChildren($folderId)));
$qb->andWhere($qb->expr()->eq('parent_folder', $qb->createNamedParameter($folderId, IQueryBuilder::PARAM_INT)));
}
$qb->executeStatement();
}
$qb->executeStatement();

}

/**
Expand Down

0 comments on commit 1ed4a56

Please sign in to comment.