From b95ffda2a105af4c6f4f86aca025a0bf967bc86a Mon Sep 17 00:00:00 2001 From: Jeremy Benoist Date: Sat, 12 Mar 2016 10:45:14 +0100 Subject: [PATCH] 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 --- .../AnnotationBundle/Repository/AnnotationRepository.php | 1 + .../Tests/Controller/AnnotationControllerTest.php | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Wallabag/AnnotationBundle/Repository/AnnotationRepository.php b/src/Wallabag/AnnotationBundle/Repository/AnnotationRepository.php index 7f35373f5..5f7da70ec 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 7a877f983..e972c2deb 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')