From b073d0c22510328b282bab9d93aa84817c4e3f00 Mon Sep 17 00:00:00 2001 From: creme332 <65414576+creme332@users.noreply.github.com> Date: Fri, 31 May 2024 08:08:06 +0400 Subject: [PATCH] handle more corner cases in displayNavigationButton --- src/views/Pagination.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/views/Pagination.php b/src/views/Pagination.php index 56dd65e..54dd056 100644 --- a/src/views/Pagination.php +++ b/src/views/Pagination.php @@ -45,7 +45,11 @@ function displayNavigationButton(int $current_page_number, int $total_pages, str $link_content = htmlspecialchars($is_left ? "<" : ">"); $className = "page-item"; - if (($current_page_number <= 1 && $is_left) || ($current_page_number >= $total_pages && !$is_left)) { + if (($current_page_number > $total_pages) || // invalid page number + ($current_page_number < 1) || // invalid page number + ($current_page_number === 1 && $is_left) || // first page + ($current_page_number === $total_pages && !$is_left) // last page + ) { $className .= " disabled"; }