Skip to content

Commit

Permalink
Prevent duplicate post format taxonomy queries (#66627)
Browse files Browse the repository at this point in the history
Add an early return to gutenberg_add_format_query_vars_to_query_loop_block if the taxonomy query already includes post formats.

Co-authored-by: carolinan <[email protected]>
Co-authored-by: Mamaduka <[email protected]>
Co-authored-by: david-binda <[email protected]>

Source: WordPress/gutenberg@99d2275
  • Loading branch information
carolinan committed Oct 31, 2024
1 parent 19b0d0d commit 83caf18
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion gutenberg.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

### BEGIN AUTO-GENERATED DEFINES
define( 'GUTENBERG_VERSION', '19.6.0' );
define( 'GUTENBERG_GIT_COMMIT', 'fbdc0f97dc463f2a2860de10b8d08cda3d8f69da' );
define( 'GUTENBERG_GIT_COMMIT', '99d22755b4e92b5bc09856b2c14a9564fb6797fc' );
### END AUTO-GENERATED DEFINES
defined( 'GUTENBERG_MINIMUM_WP_VERSION' ) or define( 'GUTENBERG_MINIMUM_WP_VERSION', '6.5' );

Expand Down
10 changes: 10 additions & 0 deletions lib/compat/wordpress-6.7/blocks.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,16 @@ function gutenberg_add_format_query_vars_to_query_loop_block( $query, $block ) {
return $query;
}

// Return early if the query already contains a post format. This is to avoid duplication if the
// WordPress core filter is already applied.
if ( ! empty( $query['tax_query'] ) ) {
foreach ( $query['tax_query'] as $taxquery ) {
if ( isset( $taxquery['taxonomy'] ) && 'post_format' === $taxquery['taxonomy'] ) {
return $query;
}
}
}

$formats = $block->context['query']['format'];
/*
* Validate that the format is either `standard` or a supported post format.
Expand Down

0 comments on commit 83caf18

Please sign in to comment.