]> source.dussan.org Git - nextcloud-server.git/commitdiff
Delete comments that expired now 33342/head
authorVitor Mattos <vitor@php.rio>
Mon, 25 Jul 2022 14:30:20 +0000 (11:30 -0300)
committerVitor Mattos <vitor@php.rio>
Mon, 25 Jul 2022 14:30:20 +0000 (11:30 -0300)
Signed-off-by: Vitor Mattos <vitor@php.rio>
lib/private/Comments/Manager.php
tests/lib/Comments/ManagerTest.php

index b82df1bccc85ae0f570c6fa50476f5e38db5435b..53603e51e5655794e74097262a986aef75951c82 100644 (file)
@@ -1652,7 +1652,7 @@ class Manager implements ICommentsManager {
        public function deleteCommentsExpiredAtObject(string $objectType, string $objectId = ''): bool {
                $qb = $this->dbConn->getQueryBuilder();
                $qb->delete('comments')
-                       ->where($qb->expr()->lt('expire_date',
+                       ->where($qb->expr()->lte('expire_date',
                                $qb->createNamedParameter($this->timeFactory->getDateTime(), IQueryBuilder::PARAM_DATE)))
                        ->andWhere($qb->expr()->eq('object_type', $qb->createNamedParameter($objectType)));
 
index ae91efb8498968b1081717c3b27eb699d9e20965..1af460e6f1bf90f34c1b9c8f1354927fe187a113 100644 (file)
@@ -753,6 +753,9 @@ class ManagerTest extends TestCase {
                $ids[] = $this->addDatabaseEntry(0, 0, null, null, 'file1', new \DateTime('-2 hours'));
                $ids[] = $this->addDatabaseEntry(0, 0, null, null, 'file2', new \DateTime('-2 hours'));
                $ids[] = $this->addDatabaseEntry(0, 0, null, null, 'file3', new \DateTime('-2 hours'));
+               $ids[] = $this->addDatabaseEntry(0, 0, null, null, 'file3', new \DateTime());
+               $ids[] = $this->addDatabaseEntry(0, 0, null, null, 'file3', new \DateTime());
+               $ids[] = $this->addDatabaseEntry(0, 0, null, null, 'file3', new \DateTime());
 
                $manager = new Manager(
                        $this->connection,
@@ -777,7 +780,7 @@ class ManagerTest extends TestCase {
                        }
                }
                $this->assertSame($exists, 0);
-               $this->assertSame($deleted, 3);
+               $this->assertSame($deleted, 6);
 
                // actor info is gone from DB, but when database interaction is alright,
                // we still expect to get true back