1
0
Fork 0
mirror of https://github.com/wallabag/wallabag.git synced 2025-07-17 17:08:37 +00:00

Fix #1551 - Redirect to the last page when current page is out of range

This commit is contained in:
Maxime LECLERCQ 2016-02-19 14:22:27 +01:00
parent fa64d86110
commit 671a2b887f
2 changed files with 19 additions and 1 deletions

View file

@ -3,6 +3,7 @@
namespace Wallabag\CoreBundle\Controller;
use Pagerfanta\Adapter\DoctrineORMAdapter;
use Pagerfanta\Exception\OutOfRangeCurrentPageException;
use Pagerfanta\Pagerfanta;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
@ -252,7 +253,13 @@ class EntryController extends Controller
$entries = new Pagerfanta($pagerAdapter);
$entries->setMaxPerPage($this->getUser()->getConfig()->getItemsPerPage());
$entries->setCurrentPage($page);
try {
$entries->setCurrentPage($page);
} catch (OutOfRangeCurrentPageException $e) {
if ($page > 1) {
return $this->redirect($this->generateUrl($type, array('page' => $entries->getNbPages())), 302);
}
}
return $this->render(
'WallabagCoreBundle:Entry:entries.html.twig',