diff options
author | Christopher Ng <chrng8@gmail.com> | 2023-08-14 18:09:24 -0700 |
---|---|---|
committer | backportbot-nextcloud[bot] <backportbot-nextcloud[bot]@users.noreply.github.com> | 2023-08-15 15:48:59 +0000 |
commit | 95688ea41291ab9e2dbb80bacea20be0c16d0774 (patch) | |
tree | 2f83761dac3d26a2f1cfef6a236e434f86fd92d3 /apps/files_reminders | |
parent | 6f879f24dbd76676d27c8a3aad327a8f9b49e24b (diff) | |
download | nextcloud-server-95688ea41291ab9e2dbb80bacea20be0c16d0774.tar.gz nextcloud-server-95688ea41291ab9e2dbb80bacea20be0c16d0774.zip |
fix(files_reminders): Delete reminders on node deleted
Signed-off-by: Christopher Ng <chrng8@gmail.com>
Diffstat (limited to 'apps/files_reminders')
-rw-r--r-- | apps/files_reminders/lib/Db/ReminderMapper.php | 9 | ||||
-rw-r--r-- | apps/files_reminders/lib/Listener/NodeDeletedListener.php | 6 |
2 files changed, 8 insertions, 7 deletions
diff --git a/apps/files_reminders/lib/Db/ReminderMapper.php b/apps/files_reminders/lib/Db/ReminderMapper.php index 1a8f05a3db9..3f7fc04b2f0 100644 --- a/apps/files_reminders/lib/Db/ReminderMapper.php +++ b/apps/files_reminders/lib/Db/ReminderMapper.php @@ -31,6 +31,7 @@ use OCP\AppFramework\Db\DoesNotExistException; use OCP\AppFramework\Db\QBMapper; use OCP\DB\QueryBuilder\IQueryBuilder; use OCP\Files\Node; +use OCP\Files\NotFoundException; use OCP\IDBConnection; use OCP\IUser; @@ -111,11 +112,17 @@ class ReminderMapper extends QBMapper { * @return Reminder[] */ public function findAllForNode(Node $node) { + try { + $nodeId = $node->getId(); + } catch (NotFoundException $e) { + return []; + } + $qb = $this->db->getQueryBuilder(); $qb->select('id', 'user_id', 'file_id', 'due_date', 'updated_at', 'created_at', 'notified') ->from($this->getTableName()) - ->where($qb->expr()->eq('file_id', $qb->createNamedParameter($node->getId(), IQueryBuilder::PARAM_INT))) + ->where($qb->expr()->eq('file_id', $qb->createNamedParameter($nodeId, IQueryBuilder::PARAM_INT))) ->orderBy('due_date', 'ASC'); return $this->findEntities($qb); diff --git a/apps/files_reminders/lib/Listener/NodeDeletedListener.php b/apps/files_reminders/lib/Listener/NodeDeletedListener.php index 460ddfd4abe..88aed08bba8 100644 --- a/apps/files_reminders/lib/Listener/NodeDeletedListener.php +++ b/apps/files_reminders/lib/Listener/NodeDeletedListener.php @@ -26,8 +26,6 @@ declare(strict_types=1); namespace OCA\FilesReminders\Listener; -use OC\Files\Node\NonExistingFile; -use OC\Files\Node\NonExistingFolder; use OCA\FilesReminders\Service\ReminderService; use OCP\EventDispatcher\Event; use OCP\EventDispatcher\IEventListener; @@ -44,10 +42,6 @@ class NodeDeletedListener implements IEventListener { } $node = $event->getNode(); - if ($node instanceof NonExistingFile || $node instanceof NonExistingFolder) { - return; - } - $this->reminderService->removeAllForNode($node); } } |