From df4992deb5799b6733b3e147d54463b6bad2fa0e Mon Sep 17 00:00:00 2001 From: Anna Larch Date: Wed, 24 Mar 2021 10:51:22 +0100 Subject: [PATCH] Add check for timestamp to hasLocks Signed-off-by: Anna Larch --- lib/Db/Mailbox.php | 8 ++++---- lib/Db/TagMapper.php | 2 +- tests/Unit/Service/Search/MailSearchTest.php | 8 +++++++- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/lib/Db/Mailbox.php b/lib/Db/Mailbox.php index b9892d2249..7ff16cba41 100644 --- a/lib/Db/Mailbox.php +++ b/lib/Db/Mailbox.php @@ -119,14 +119,14 @@ public function isCached(): bool { && $this->getSyncVanishedToken() !== null; } - public function hasLocks( int $now ): bool { - if( $this->getSyncNewLock() !== null || $this->getSyncNewLock() > ( $now - MailboxMapper::LOCK) ) { + public function hasLocks(int $now): bool { + if ($this->getSyncNewLock() !== null || $this->getSyncNewLock() > ($now - MailboxMapper::LOCK)) { return true; } - if( $this->getSyncChangedLock() !== null || $this->getSyncChangedLock() > ( $now - MailboxMapper::LOCK) ) { + if ($this->getSyncChangedLock() !== null || $this->getSyncChangedLock() > ($now - MailboxMapper::LOCK)) { return true; } - if( $this->getSyncVanishedLock() !== null || $this->getSyncVanishedLock() > ( $now - MailboxMapper::LOCK) ) { + if ($this->getSyncVanishedLock() !== null || $this->getSyncVanishedLock() > ($now - MailboxMapper::LOCK)) { return true; } return false; diff --git a/lib/Db/TagMapper.php b/lib/Db/TagMapper.php index 2195902239..4ce489cc4b 100644 --- a/lib/Db/TagMapper.php +++ b/lib/Db/TagMapper.php @@ -158,7 +158,7 @@ public function getAllTagsForMessages(array $messages): array { foreach ($queryResult as $qr) { $result[] = $qr['imap_message_id']; $result[$qr['imap_message_id']][] = $this->getTag((int)$qr['tag_id']); - }; + } return $result; } diff --git a/tests/Unit/Service/Search/MailSearchTest.php b/tests/Unit/Service/Search/MailSearchTest.php index 534bc076fc..d08b581a7a 100644 --- a/tests/Unit/Service/Search/MailSearchTest.php +++ b/tests/Unit/Service/Search/MailSearchTest.php @@ -39,6 +39,7 @@ use OCA\Mail\Service\Search\Flag; use OCA\Mail\Service\Search\MailSearch; use OCA\Mail\Service\Search\SearchQuery; +use OCP\AppFramework\Utility\ITimeFactory; use PHPUnit\Framework\MockObject\MockObject; class MailSearchTest extends TestCase { @@ -61,6 +62,9 @@ class MailSearchTest extends TestCase { /** @var MessageMapper|MockObject */ private $messageMapper; + /** @var ITimeFactory|MockObject */ + private $timeFactory; + protected function setUp(): void { parent::setUp(); @@ -69,13 +73,15 @@ protected function setUp(): void { $this->imapSearchProvider = $this->createMock(Provider::class); $this->messageMapper = $this->createMock(MessageMapper::class); $this->previewEnhancer = $this->createMock(PreviewEnhancer::class); + $this->timeFactory = $this->createMock(ITimeFactory::class); $this->search = new MailSearch( $this->filterStringParser, $this->mailboxMapper, $this->imapSearchProvider, $this->messageMapper, - $this->previewEnhancer + $this->previewEnhancer, + $this->timeFactory ); }