mirror of
https://github.com/WordPress/WordPress.git
synced 2025-01-03 06:57:35 +01:00
Editor: Sets 'paged' query arg only when there are comments: build_comment_query_vars_from_block()
.
A SQL syntax error happened when a post has no comments and "Break comments into pages" is checked in Settings > Discussion. The fix sets the `'paged'` query arg only when there are comments. When there are no comments, `WP_Comment_Query` sets the default `'paged'` value to `1`. Props bernhard-reiter, luisherranz, czapla, cbravobernal, davidbaumwald, hellofromTonya. Follow-up to [53142], [53138]. Fixes #55658. Built from https://develop.svn.wordpress.org/trunk@53336 git-svn-id: http://core.svn.wordpress.org/trunk@52925 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
0c9c1d5297
commit
7b880889bc
@ -1325,7 +1325,10 @@ function build_comment_query_vars_from_block( $block ) {
|
||||
} elseif ( 'oldest' === $default_page ) {
|
||||
$comment_args['paged'] = 1;
|
||||
} elseif ( 'newest' === $default_page ) {
|
||||
$comment_args['paged'] = (int) ( new WP_Comment_Query( $comment_args ) )->max_num_pages;
|
||||
$max_num_pages = (int) ( new WP_Comment_Query( $comment_args ) )->max_num_pages;
|
||||
if ( 0 !== $max_num_pages ) {
|
||||
$comment_args['paged'] = $max_num_pages;
|
||||
}
|
||||
}
|
||||
// Set the `cpage` query var to ensure the previous and next pagination links are correct
|
||||
// when inheriting the Discussion Settings.
|
||||
|
@ -16,7 +16,7 @@
|
||||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '6.0-beta4-53335';
|
||||
$wp_version = '6.0-beta4-53336';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
Loading…
Reference in New Issue
Block a user