diff options
author | Nicolas LÅ“uillet <nicolas@loeuillet.org> | 2016-04-12 16:40:18 +0200 |
---|---|---|
committer | Nicolas LÅ“uillet <nicolas@loeuillet.org> | 2016-04-12 16:40:18 +0200 |
commit | 1880da742027ec08f73e116143f2f514155ab7fd (patch) | |
tree | add5f3b5bc2987f7cc33a55048ec733294105d52 /src | |
parent | 76cd8dbb059ebec2d0650089424681afc9bd6b0b (diff) | |
download | wallabag-1880da742027ec08f73e116143f2f514155ab7fd.tar.gz wallabag-1880da742027ec08f73e116143f2f514155ab7fd.tar.zst wallabag-1880da742027ec08f73e116143f2f514155ab7fd.zip |
Restore old behavior for OutOfRangeCurrentPageException
Diffstat (limited to 'src')
-rw-r--r-- | src/Wallabag/CoreBundle/Controller/EntryController.php | 9 | ||||
-rw-r--r-- | src/Wallabag/CoreBundle/Tests/Controller/EntryControllerTest.php | 3 |
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 @@ | |||
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 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 | /** |