fix: cast division results to integer for pagination calculations#402
fix: cast division results to integer for pagination calculations#402
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 3d4f92dda5
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| private function getNumberOfPage() | ||
| { | ||
| return $this->int_nbr_row / $this->int_num_result; | ||
| return (int)ceil($this->int_nbr_row / $this->int_num_result); |
There was a problem hiding this comment.
Preserve ratio used by getCurrentPage calculation
Changing getNumberOfPage() to ceil(...) breaks the algebra that getCurrentPage() relies on (($int_cur_position * getNumberOfPage()) / $int_nbr_row), so non-even totals can round to the wrong page index. For example with 4 rows, page size 3, and int_cur_position=3, getCurrentPage() becomes 1.5 and number_format(..., 0) returns 2, which is outside valid indexes 0..1; this leaves no page marked as current (or marks the wrong one) in pagers that consume getPagingRowArray().
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Pull request overview
このPRは、レポートモジュールのページネーションロジックを改善し、ページ計算の堅牢性を向上させ、多数のページがある場合のページナビゲーションの問題を修正する。
Changes:
getNumberOfPageメソッドでceil()と整数キャストを使用し、常に正しい整数のページ数を返すように修正logging.static.phpの$current_row計算で除算結果を明示的に整数にキャストし、配列アクセス時のエラーを回避- 6ページ以上ある場合のページリンク表示ロジックをリファクタリングし、配列範囲外エラーを回避しながら連続した5つのページリンクを表示
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| manager/includes/paginate.inc.php | getNumberOfPage() メソッドに ceil() と整数キャストを追加し、総行数がページサイズの倍数でない場合でも正しいページ数を返すように修正 |
| manager/actions/report/logging.static.php | $current_row の計算に整数キャストを追加し、6ページ以上の場合のページナビゲーション表示ロジックを改善して境界チェックを適切に実装 |
This pull request improves the pagination logic in the reporting module to make page calculations more robust and to fix issues with page navigation when there are many pages. The main changes ensure that page numbers are always integers and that the correct range of page links is displayed.
Improvements to pagination calculations:
getNumberOfPagemethod inpaginate.inc.phpto always return an integer number of pages usingceil, preventing potential issues when the total row count isn't a multiple of the page size.$current_rowinlogging.static.phpis always an integer by explicitly casting the result of the division, which avoids errors when accessing the paging array.Enhancements to page navigation display:
logging.static.php, so that a continuous block of five page links is shown, starting from the appropriate page and avoiding out-of-bounds errors.