Skip to content

Comments

fix: cast division results to integer for pagination calculations#402

Merged
yama merged 1 commit intomainfrom
hotfix/t-2034
Feb 14, 2026
Merged

fix: cast division results to integer for pagination calculations#402
yama merged 1 commit intomainfrom
hotfix/t-2034

Conversation

@yama
Copy link
Member

@yama yama commented Feb 13, 2026

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:

  • Updated the getNumberOfPage method in paginate.inc.php to always return an integer number of pages using ceil, preventing potential issues when the total row count isn't a multiple of the page size.
  • Ensured that $current_row in logging.static.php is always an integer by explicitly casting the result of the division, which avoids errors when accessing the paging array.

Enhancements to page navigation display:

  • Refactored the logic for displaying page links when there are more than six pages in 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.

Copilot AI review requested due to automatic review settings February 13, 2026 15:06
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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ページ以上の場合のページナビゲーション表示ロジックを改善して境界チェックを適切に実装

@yama yama merged commit 5c801fe into main Feb 14, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant