From: Thomas Citharel Date: Wed, 10 May 2017 07:38:55 +0000 (+0200) Subject: Merge pull request #3095 from aaa2000/api-error-on-fail-fetch-content X-Git-Tag: 2.2.3~5 X-Git-Url: https://git.immae.eu/?a=commitdiff_plain;h=91ba9a59754b09f0713161567d36c959c2aa5ffe;hp=a9357a8311b2a3a9a114ec8400a9878d5f1f8345;p=github%2Fwallabag%2Fwallabag.git Merge pull request #3095 from aaa2000/api-error-on-fail-fetch-content Create a new entry via API even when its content can't be retrieved --- diff --git a/src/Wallabag/ApiBundle/Controller/EntryRestController.php b/src/Wallabag/ApiBundle/Controller/EntryRestController.php index e9e1aca3..54c1747c 100644 --- a/src/Wallabag/ApiBundle/Controller/EntryRestController.php +++ b/src/Wallabag/ApiBundle/Controller/EntryRestController.php @@ -98,12 +98,13 @@ class EntryRestController extends WallabagRestController $tags = $request->query->get('tags', ''); $since = $request->query->get('since', 0); + /** @var \Pagerfanta\Pagerfanta $pager */ $pager = $this->getDoctrine() ->getRepository('WallabagCoreBundle:Entry') ->findEntries($this->getUser()->getId(), $isArchived, $isStarred, $sort, $order, $since, $tags); - $pager->setCurrentPage($page); $pager->setMaxPerPage($perPage); + $pager->setCurrentPage($page); $pagerfantaFactory = new PagerfantaFactory('page', 'perPage'); $paginatedCollection = $pagerfantaFactory->createRepresentation( diff --git a/src/Wallabag/CoreBundle/Form/Type/EntryFilterType.php b/src/Wallabag/CoreBundle/Form/Type/EntryFilterType.php index ee66c728..556578d1 100644 --- a/src/Wallabag/CoreBundle/Form/Type/EntryFilterType.php +++ b/src/Wallabag/CoreBundle/Form/Type/EntryFilterType.php @@ -3,6 +3,7 @@ namespace Wallabag\CoreBundle\Form\Type; use Doctrine\ORM\EntityRepository; +use Lexik\Bundle\FormFilterBundle\Filter\FilterOperands; use Lexik\Bundle\FormFilterBundle\Filter\Query\QueryInterface; use Lexik\Bundle\FormFilterBundle\Filter\Form\Type\NumberRangeFilterType; use Lexik\Bundle\FormFilterBundle\Filter\Form\Type\DateRangeFilterType; @@ -33,7 +34,7 @@ class EntryFilterType extends AbstractType $this->user = $tokenStorage->getToken() ? $tokenStorage->getToken()->getUser() : null; if (null === $this->user || !is_object($this->user)) { - return null; + return; } } @@ -41,6 +42,14 @@ class EntryFilterType extends AbstractType { $builder ->add('readingTime', NumberRangeFilterType::class, [ + 'left_number_options' => [ + 'condition_operator' => FilterOperands::OPERATOR_GREATER_THAN_EQUAL, + 'attr' => ['min' => 0], + ], + 'right_number_options' => [ + 'condition_operator' => FilterOperands::OPERATOR_LOWER_THAN_EQUAL, + 'attr' => ['min' => 0], + ], 'apply_filter' => function (QueryInterface $filterQuery, $field, $values) { $lower = $values['value']['left_number'][0]; $upper = $values['value']['right_number'][0]; diff --git a/src/Wallabag/CoreBundle/Resources/views/themes/common/Static/about.html.twig b/src/Wallabag/CoreBundle/Resources/views/themes/common/Static/about.html.twig index db193e81..f82e5dc5 100644 --- a/src/Wallabag/CoreBundle/Resources/views/themes/common/Static/about.html.twig +++ b/src/Wallabag/CoreBundle/Resources/views/themes/common/Static/about.html.twig @@ -106,8 +106,8 @@ hoa/zformatBSD-3-Clause htmlawed/htmlawedGPL-2.0+ or LGPL-3.0 incenteev/composer-parameter-handlerMIT - j0k3r/grabyAGPL-3.0 - j0k3r/graby-site-configAGPL-3.0 + j0k3r/grabyMIT + j0k3r/graby-site-configPublic domain j0k3r/php-readabilityApache-2.0 j0k3r/safecurlMIT jdorn/sql-formatterMIT diff --git a/tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php b/tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php index deafd1fa..0a65f9ce 100644 --- a/tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php +++ b/tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php @@ -157,6 +157,22 @@ class EntryRestControllerTest extends WallabagApiTestCase $this->assertEquals('application/json', $this->client->getResponse()->headers->get('Content-Type')); } + public function testGetEntriesOnPageTwo() + { + $this->client->request('GET', '/api/entries', [ + 'page' => 2, + 'perPage' => 2, + ]); + + $this->assertEquals(200, $this->client->getResponse()->getStatusCode()); + + $content = json_decode($this->client->getResponse()->getContent(), true); + + $this->assertGreaterThanOrEqual(0, $content['total']); + $this->assertEquals(2, $content['page']); + $this->assertEquals(2, $content['limit']); + } + public function testGetStarredEntries() { $this->client->request('GET', '/api/entries', ['starred' => 1, 'sort' => 'updated']); diff --git a/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php b/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php index 3eb6d47f..7db4cf1f 100644 --- a/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php +++ b/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php @@ -591,6 +591,26 @@ class EntryControllerTest extends WallabagCoreTestCase $this->assertCount(1, $crawler->filter('div[class=entry]')); } + public function testFilterOnReadingTimeWithNegativeValue() + { + $this->logInAs('admin'); + $client = $this->getClient(); + + $crawler = $client->request('GET', '/unread/list'); + + $form = $crawler->filter('button[id=submit-filter]')->form(); + + $data = [ + 'entry_filter[readingTime][right_number]' => -22, + 'entry_filter[readingTime][left_number]' => -22, + ]; + + $crawler = $client->submit($form, $data); + + // forcing negative value results in no entry displayed + $this->assertCount(0, $crawler->filter('div[class=entry]')); + } + public function testFilterOnReadingTimeOnlyUpper() { $this->logInAs('admin');