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: Fix warning returned by comments pagination blocks #65435

Merged

Conversation

SantosGuillamot
Copy link
Contributor

@SantosGuillamot SantosGuillamot commented Sep 18, 2024

What?

Fixes #65424

Why?

It shouldn't return a warning in that scenario.

How?

I added a safety check to return null when $comment_vars['paged'] is not defined.

I couldn't adapt the e2e tests because the testing instance has WP_DEBUG set to false and doesn't show warnings.

Testing Instructions

  1. Go to Settings->Discussion and check you have "Break comments into pages with 2 top level comments per page and the last page displayed by default.
  2. Go to a post with NO comments and add the comments block.
  3. Go to the frontend and check that the warning is not there anymore.

@SantosGuillamot SantosGuillamot added [Type] Bug An existing feature does not function as intended [Block] Comments Pagination Previous Affects the Comments Pagination Previous Block [Block] Comment Pagination Next Affects the Comments Pagination Next Block labels Sep 18, 2024
Copy link

github-actions bot commented Sep 18, 2024

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: SantosGuillamot <santosguillamot@git.wordpress.org>
Co-authored-by: gziolo <gziolo@git.wordpress.org>
Co-authored-by: michalczaplinski <czapla@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@@ -37,7 +37,7 @@ function render_block_core_comments_pagination_next( $attributes, $content, $blo
$label .= $pagination_arrow;
}

$next_comments_link = get_next_comments_link( $label, $max_page, $comment_vars['paged'] );
$next_comments_link = get_next_comments_link( $label, $max_page, $comment_vars['paged'] ?? null );
Copy link
Member

Choose a reason for hiding this comment

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

Finally, we can use PHP 7 features everywhere. How nice!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Comment Pagination Next Affects the Comments Pagination Next Block [Block] Comments Pagination Previous Affects the Comments Pagination Previous Block [Type] Bug An existing feature does not function as intended
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Undefined array key "paged" in comments-pagination-previous.php
2 participants