From 8686b620281b4edc59fa3e3f735ccb64e3680eaf Mon Sep 17 00:00:00 2001 From: Geert De Deckere Date: Sun, 2 Aug 2009 15:08:30 +0200 Subject: [PATCH] Better recalculation check in setup() --- classes/kohana/pagination.php | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/classes/kohana/pagination.php b/classes/kohana/pagination.php index 3cb4a0d..c6b85b6 100644 --- a/classes/kohana/pagination.php +++ b/classes/kohana/pagination.php @@ -108,9 +108,13 @@ class Kohana_Pagination { // Overwrite the current config settings $this->config = array_merge($this->config, $config); - // Retrieve the current page number - if (isset($config['current_page'])) + // Only (re)calculate pagination when needed + if ($this->current_page === NULL + OR isset($config['current_page']) + OR isset($config['total_items']) + OR isset($config['items_per_page'])) { + // Retrieve the current page number switch ($this->config['current_page']['source']) { case 'query': @@ -122,15 +126,8 @@ class Kohana_Pagination { case 'route': $this->current_page = (int) Request::instance()->param($this->config['current_page']['key'], 1); break; - - default: - $this->current_page = 1; } - } - // Only (re)calculate pagination when needed - if (isset($config['current_page']) OR isset($config['total_items']) OR isset($config['items_per_page'])) - { // Calculate and clean all pagination variables $this->total_items = (int) max(0, $this->config['total_items']); $this->items_per_page = (int) max(1, $this->config['items_per_page']); -- 2.11.4.GIT