Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Comments Pagination Next block: fix accidental division by zero #37788

Conversation

luisherranz
Copy link
Member

Description

What

It fixes #37785, a small bug of the Comments Pagination Next block that triggers a division by zero warning when no per_page was set in either the parent Comments Query Loop block or in the WordPress settings.

Why

Under those conditions, it was possible to run a division by zero in the code.

How

I replaced an isset( $per_page ) which always returns true for a comparison of 0 !== $per_page.

How has this been tested?

I tested it manually by adding a new Comment Query Loop block in a WordPress site with the default comments configuration.

Screenshots

I made a small video to explain the problem and this possible solution in more detail: https://www.loom.com/share/3aa2b9d8ab73417bac074a7c7d84cd50

Types of changes

This is a bug fix.

Checklist:

  • My code is manually tested.
  • My code follows the WordPress code style.

@luisherranz luisherranz added [Type] Bug An existing feature does not function as intended [Block] Comments Affects the Comments Block - formerly known as Comments Query Loop labels Jan 7, 2022
@luisherranz luisherranz requested a review from ajitbohra as a code owner January 7, 2022 18:18
@luisherranz luisherranz self-assigned this Jan 7, 2022
Copy link
Contributor

@cbravobernal cbravobernal left a comment

Choose a reason for hiding this comment

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

LGTM!

@cbravobernal cbravobernal merged commit c9ba458 into trunk Jan 10, 2022
@cbravobernal cbravobernal deleted the fix/comments-pagination-next-block-accidental-division-by-zero branch January 10, 2022 09:58
@github-actions github-actions bot added this to the Gutenberg 12.4 milestone Jan 10, 2022
@luisherranz
Copy link
Member Author

Thanks Carlos 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Comments Affects the Comments Block - formerly known as Comments Query Loop [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Comments Pagination Next block: accidental division by zero
2 participants