From d2f6c583bba35787b450348b267c310c4e10cbde Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elan=20Ruusam=C3=A4e?= Date: Fri, 23 Oct 2020 07:07:03 +0300 Subject: [PATCH 1/2] Add DEFAULT_PAGE constant --- src/Xhgui/Controller/RunController.php | 2 +- src/Xhgui/Searcher/SearcherInterface.php | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Xhgui/Controller/RunController.php b/src/Xhgui/Controller/RunController.php index 6c8497301..79f8a5e75 100644 --- a/src/Xhgui/Controller/RunController.php +++ b/src/Xhgui/Controller/RunController.php @@ -46,7 +46,7 @@ public function index(Request $request, Response $response) $result = $this->searcher->getAll([ 'sort' => $sort, - 'page' => $request->get('page'), + 'page' => (int)$request->get('page', SearcherInterface::DEFAULT_PAGE), 'direction' => $request->get('direction'), 'perPage' => $this->app->config('page.limit'), 'conditions' => $search, diff --git a/src/Xhgui/Searcher/SearcherInterface.php b/src/Xhgui/Searcher/SearcherInterface.php index fa4a6182e..c1db386da 100644 --- a/src/Xhgui/Searcher/SearcherInterface.php +++ b/src/Xhgui/Searcher/SearcherInterface.php @@ -12,6 +12,7 @@ interface SearcherInterface { const DEFAULT_DIRECTION = 'desc'; + const DEFAULT_PAGE = 1; /** * Get the latest profile data. From 44fa536de5da1a0f06de8632890d602774caf5cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elan=20Ruusam=C3=A4e?= Date: Fri, 23 Oct 2020 16:23:49 +0300 Subject: [PATCH 2/2] Cast to integer page.limit --- src/Xhgui/Controller/RunController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Xhgui/Controller/RunController.php b/src/Xhgui/Controller/RunController.php index 79f8a5e75..a8688e62d 100644 --- a/src/Xhgui/Controller/RunController.php +++ b/src/Xhgui/Controller/RunController.php @@ -48,7 +48,7 @@ public function index(Request $request, Response $response) 'sort' => $sort, 'page' => (int)$request->get('page', SearcherInterface::DEFAULT_PAGE), 'direction' => $request->get('direction'), - 'perPage' => $this->app->config('page.limit'), + 'perPage' => (int)$this->app->config('page.limit'), 'conditions' => $search, 'projection' => true, ]);