From b95ffda2a105af4c6f4f86aca025a0bf967bc86a Mon Sep 17 00:00:00 2001 From: Jeremy Benoist Date: Sat, 12 Mar 2016 10:45:14 +0100 Subject: Fix hazardous bug with Postgres Instead of retrieving a random annotation, sort them to be sure they are all the same no matter the database used --- src/Wallabag/AnnotationBundle/Repository/AnnotationRepository.php | 1 + .../AnnotationBundle/Tests/Controller/AnnotationControllerTest.php | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) (limited to 'src/Wallabag') diff --git a/src/Wallabag/AnnotationBundle/Repository/AnnotationRepository.php b/src/Wallabag/AnnotationBundle/Repository/AnnotationRepository.php index 7f35373f..5f7da70e 100644 --- a/src/Wallabag/AnnotationBundle/Repository/AnnotationRepository.php +++ b/src/Wallabag/AnnotationBundle/Repository/AnnotationRepository.php @@ -101,6 +101,7 @@ class AnnotationRepository extends EntityRepository return $this->createQueryBuilder('a') ->leftJoin('a.user', 'u') ->where('u.username = :username')->setParameter('username', $username) + ->orderBy('a.id', 'DESC') ->setMaxResults(1) ->getQuery() ->getSingleResult(); diff --git a/src/Wallabag/AnnotationBundle/Tests/Controller/AnnotationControllerTest.php b/src/Wallabag/AnnotationBundle/Tests/Controller/AnnotationControllerTest.php index 7a877f98..e972c2de 100644 --- a/src/Wallabag/AnnotationBundle/Tests/Controller/AnnotationControllerTest.php +++ b/src/Wallabag/AnnotationBundle/Tests/Controller/AnnotationControllerTest.php @@ -81,7 +81,7 @@ class AnnotationControllerTest extends WallabagAnnotationTestCase $this->assertEquals('Big boss', $content['user']); $this->assertEquals('v1.0', $content['annotator_schema_version']); $this->assertEquals('a modified annotation', $content['text']); - $this->assertEquals('content', $content['quote']); + $this->assertEquals('my quote', $content['quote']); $annotationUpdated = $this->client->getContainer() ->get('doctrine.orm.entity_manager') -- cgit v1.2.3