Skip to content

Fix guard against pageSize <= 0 causing division by zero in initPagination#8294

Merged
wenzhixin merged 1 commit into
developfrom
fix/pagination-pagesize-guard
Apr 15, 2026
Merged

Fix guard against pageSize <= 0 causing division by zero in initPagination#8294
wenzhixin merged 1 commit into
developfrom
fix/pagination-pagesize-guard

Conversation

@wenzhixin
Copy link
Copy Markdown
Owner

🤔Type of Request

  • Bug fix
  • New feature
  • Improvement
  • Documentation
  • Other

🔗Resolves an issue?
Replaces #8271

📝Changelog

  • Core
  • Extensions

Fix division by zero when pageSize is 0 or negative by moving the guard before if (opts.totalRows) to also cover the pageFrom/pageTo calculation. Added console.warn for invalid input to help developers detect configuration errors.

💡Example(s)?

☑️Self Check before Merge

⚠️ Please check all items below before reviewing. ⚠️

  • Doc is updated/provided or not needed
  • Demo is updated/provided or not needed
  • Changelog is provided or not needed

Copy link
Copy Markdown
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

Fixes a division-by-zero edge case in the core pagination module when pageSize is configured as 0 or a negative number, ensuring pageFrom/pageTo and totalPages calculations remain safe during initPagination().

Changes:

  • Adds an early guard for opts.pageSize <= 0 to prevent invalid pagination math.
  • Falls back to “show all rows” behavior for invalid pageSize values and logs a console.warn to aid debugging.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@wenzhixin wenzhixin merged commit 6d62c8e into develop Apr 15, 2026
5 checks passed
@wenzhixin wenzhixin deleted the fix/pagination-pagesize-guard branch April 15, 2026 16:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants