mirror of
https://github.com/wallabag/wallabag.git
synced 2024-11-23 17:41:01 +00:00
Restore old behavior for OutOfRangeCurrentPageException
This commit is contained in:
parent
76cd8dbb05
commit
1880da7420
2 changed files with 10 additions and 2 deletions
|
@ -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());
|
||||
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',
|
||||
|
|
|
@ -225,7 +225,8 @@ class EntryControllerTest extends WallabagCoreTestCase
|
|||
|
||||
$client->request('GET', '/all/list/900');
|
||||
|
||||
$this->assertEquals(404, $client->getResponse()->getStatusCode());
|
||||
$this->assertEquals(302, $client->getResponse()->getStatusCode());
|
||||
$this->assertEquals('/all/list', $client->getResponse()->getTargetUrl());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue