Merge pull request #33342 from nextcloud/bugfix/delete-comments-that-have-expired-now

Delete comments that expired now
pull/33349/head
blizzz 2022-07-25 17:46:41 +07:00 committed by GitHub
commit c523fd1ed7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 2 deletions

@ -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)));

@ -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