diff options
-rw-r--r-- | src/Wallabag/CoreBundle/Controller/EntryController.php | 9 | ||||
-rw-r--r-- | src/Wallabag/CoreBundle/Tests/Controller/EntryControllerTest.php | 11 |
2 files changed, 19 insertions, 1 deletions
diff --git a/src/Wallabag/CoreBundle/Controller/EntryController.php b/src/Wallabag/CoreBundle/Controller/EntryController.php index ea77d138..0fae3a0f 100644 --- a/src/Wallabag/CoreBundle/Controller/EntryController.php +++ b/src/Wallabag/CoreBundle/Controller/EntryController.php | |||
@@ -3,6 +3,7 @@ | |||
3 | namespace Wallabag\CoreBundle\Controller; | 3 | namespace Wallabag\CoreBundle\Controller; |
4 | 4 | ||
5 | use Pagerfanta\Adapter\DoctrineORMAdapter; | 5 | use Pagerfanta\Adapter\DoctrineORMAdapter; |
6 | use Pagerfanta\Exception\OutOfRangeCurrentPageException; | ||
6 | use Pagerfanta\Pagerfanta; | 7 | use Pagerfanta\Pagerfanta; |
7 | use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; | 8 | use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; |
8 | use Symfony\Bundle\FrameworkBundle\Controller\Controller; | 9 | use Symfony\Bundle\FrameworkBundle\Controller\Controller; |
@@ -252,7 +253,13 @@ class EntryController extends Controller | |||
252 | $entries = new Pagerfanta($pagerAdapter); | 253 | $entries = new Pagerfanta($pagerAdapter); |
253 | 254 | ||
254 | $entries->setMaxPerPage($this->getUser()->getConfig()->getItemsPerPage()); | 255 | $entries->setMaxPerPage($this->getUser()->getConfig()->getItemsPerPage()); |
255 | $entries->setCurrentPage($page); | 256 | try { |
257 | $entries->setCurrentPage($page); | ||
258 | } catch (OutOfRangeCurrentPageException $e) { | ||
259 | if ($page > 1) { | ||
260 | return $this->redirect($this->generateUrl($type, array('page' => $entries->getNbPages())), 302); | ||
261 | } | ||
262 | } | ||
256 | 263 | ||
257 | return $this->render( | 264 | return $this->render( |
258 | 'WallabagCoreBundle:Entry:entries.html.twig', | 265 | 'WallabagCoreBundle:Entry:entries.html.twig', |
diff --git a/src/Wallabag/CoreBundle/Tests/Controller/EntryControllerTest.php b/src/Wallabag/CoreBundle/Tests/Controller/EntryControllerTest.php index 32d6a575..5512d6e1 100644 --- a/src/Wallabag/CoreBundle/Tests/Controller/EntryControllerTest.php +++ b/src/Wallabag/CoreBundle/Tests/Controller/EntryControllerTest.php | |||
@@ -216,6 +216,17 @@ class EntryControllerTest extends WallabagCoreTestCase | |||
216 | $this->assertEquals(200, $client->getResponse()->getStatusCode()); | 216 | $this->assertEquals(200, $client->getResponse()->getStatusCode()); |
217 | } | 217 | } |
218 | 218 | ||
219 | public function testRangeException() | ||
220 | { | ||
221 | $this->logInAs('admin'); | ||
222 | $client = $this->getClient(); | ||
223 | |||
224 | $client->request('GET', '/all/list/900'); | ||
225 | |||
226 | $this->assertEquals(302, $client->getResponse()->getStatusCode()); | ||
227 | $this->assertEquals('/all/list', $client->getResponse()->getTargetUrl()); | ||
228 | } | ||
229 | |||
219 | /** | 230 | /** |
220 | * @depends testPostNewOk | 231 | * @depends testPostNewOk |
221 | */ | 232 | */ |