From 18e1106f768dfbf2e4b4a3e0dbbf789c27ef83e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20L=C5=93uillet?= Date: Sat, 29 Jul 2023 10:18:11 +0200 Subject: [PATCH] Add articles which have annotations with search term in results Fix #3635 --- .../CoreBundle/Repository/EntryRepository.php | 4 +++- .../CoreBundle/Controller/EntryControllerTest.php | 11 +++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/Wallabag/CoreBundle/Repository/EntryRepository.php b/src/Wallabag/CoreBundle/Repository/EntryRepository.php index 9dded5e57..ba731daf7 100644 --- a/src/Wallabag/CoreBundle/Repository/EntryRepository.php +++ b/src/Wallabag/CoreBundle/Repository/EntryRepository.php @@ -133,8 +133,10 @@ class EntryRepository extends ServiceEntityRepository // We lower() all parts here because PostgreSQL 'LIKE' verb is case-sensitive $qb - ->andWhere('lower(e.content) LIKE lower(:term) OR lower(e.title) LIKE lower(:term) OR lower(e.url) LIKE lower(:term)')->setParameter('term', '%' . $term . '%') + ->andWhere('lower(e.content) LIKE lower(:term) OR lower(e.title) LIKE lower(:term) OR lower(e.url) LIKE lower(:term) OR lower(a.text) LIKE lower(:term)') + ->setParameter('term', '%' . $term . '%') ->leftJoin('e.tags', 't') + ->leftJoin('e.annotations', 'a') ->groupBy('e.id'); return $qb; diff --git a/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php b/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php index a6e0f395b..8124474d6 100644 --- a/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php +++ b/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php @@ -1471,6 +1471,17 @@ class EntryControllerTest extends WallabagCoreTestCase $crawler = $client->submit($form, $data); $this->assertCount(1, $crawler->filter($this->entryDataTestAttribute)); + + $crawler = $client->request('GET', '/unread/list'); + + $form = $crawler->filter('form[name=search]')->form(); + $data = [ + 'search_entry[term]' => 'annotation', + ]; + + $crawler = $client->submit($form, $data); + + $this->assertCount(2, $crawler->filter($this->entryDataTestAttribute)); } public function dataForLanguage()