Skip to content

Commit

Permalink
Query Total: Prevent stricted type fatal errors on post per page. (Wo…
Browse files Browse the repository at this point in the history
…rdPress#69508)

Co-authored-by: cbravobernal <cbravobernal@git.wordpress.org>
Co-authored-by: Mamaduka <mamaduka@git.wordpress.org>
Co-authored-by: gziolo <gziolo@git.wordpress.org>
  • Loading branch information
4 people authored Mar 10, 2025
1 parent 66394c4 commit 90d34ff
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/block-library/src/query-total/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ function render_block_core_query_total( $attributes, $content, $block ) {
$wrapper_attributes = get_block_wrapper_attributes();
if ( isset( $block->context['query']['inherit'] ) && $block->context['query']['inherit'] ) {
$query_to_use = $wp_query;
$current_page = max( 1, get_query_var( 'paged', 1 ) );
$current_page = max( 1, (int) get_query_var( 'paged', 1 ) );
} else {
$page_key = isset( $block->context['queryId'] ) ? 'query-' . $block->context['queryId'] . '-page' : 'query-page';
$current_page = isset( $_GET[ $page_key ] ) ? (int) $_GET[ $page_key ] : 1;
$query_to_use = new WP_Query( build_query_vars_from_query_block( $block, $current_page ) );
}

$max_rows = $query_to_use->found_posts;
$posts_per_page = $query_to_use->get( 'posts_per_page' );
$posts_per_page = (int) $query_to_use->get( 'posts_per_page' );

// Calculate the range of posts being displayed.
$start = ( $current_page - 1 ) * $posts_per_page + 1;
Expand Down

0 comments on commit 90d34ff

Please sign in to comment.