aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorNicolas LÅ“uillet <nicolas@loeuillet.org>2016-04-12 16:40:18 +0200
committerNicolas LÅ“uillet <nicolas@loeuillet.org>2016-04-12 16:40:18 +0200
commit1880da742027ec08f73e116143f2f514155ab7fd (patch)
treeadd5f3b5bc2987f7cc33a55048ec733294105d52
parent76cd8dbb059ebec2d0650089424681afc9bd6b0b (diff)
downloadwallabag-1880da742027ec08f73e116143f2f514155ab7fd.tar.gz
wallabag-1880da742027ec08f73e116143f2f514155ab7fd.tar.zst
wallabag-1880da742027ec08f73e116143f2f514155ab7fd.zip
Restore old behavior for OutOfRangeCurrentPageException
-rw-r--r--src/Wallabag/CoreBundle/Controller/EntryController.php9
-rw-r--r--src/Wallabag/CoreBundle/Tests/Controller/EntryControllerTest.php3
2 files changed, 10 insertions, 2 deletions
diff --git a/src/Wallabag/CoreBundle/Controller/EntryController.php b/src/Wallabag/CoreBundle/Controller/EntryController.php
index e6077707..cba58858 100644
--- a/src/Wallabag/CoreBundle/Controller/EntryController.php
+++ b/src/Wallabag/CoreBundle/Controller/EntryController.php
@@ -3,6 +3,7 @@
3namespace Wallabag\CoreBundle\Controller; 3namespace Wallabag\CoreBundle\Controller;
4 4
5use Pagerfanta\Adapter\DoctrineORMAdapter; 5use Pagerfanta\Adapter\DoctrineORMAdapter;
6use Pagerfanta\Exception\OutOfRangeCurrentPageException;
6use Pagerfanta\Pagerfanta; 7use Pagerfanta\Pagerfanta;
7use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; 8use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
8use Symfony\Bundle\FrameworkBundle\Controller\Controller; 9use 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 2d846454..a3527898 100644
--- a/src/Wallabag/CoreBundle/Tests/Controller/EntryControllerTest.php
+++ b/src/Wallabag/CoreBundle/Tests/Controller/EntryControllerTest.php
@@ -225,7 +225,8 @@ class EntryControllerTest extends WallabagCoreTestCase
225 225
226 $client->request('GET', '/all/list/900'); 226 $client->request('GET', '/all/list/900');
227 227
228 $this->assertEquals(404, $client->getResponse()->getStatusCode()); 228 $this->assertEquals(302, $client->getResponse()->getStatusCode());
229 $this->assertEquals('/all/list', $client->getResponse()->getTargetUrl());
229 } 230 }
230 231
231 /** 232 /**