Changeset 59761
- Timestamp:
- 02/04/2025 08:59:04 AM (12 days ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/blocks.php
r59543 r59761 2639 2639 } 2640 2640 if ( ! empty( $block->context['query']['parents'] ) && is_post_type_hierarchical( $query['post_type'] ) ) { 2641 $query['post_parent__in'] = array_ filter( array_map( 'intval', $block->context['query']['parents'] ) );2641 $query['post_parent__in'] = array_unique( array_map( 'intval', $block->context['query']['parents'] ) ); 2642 2642 } 2643 2643 } -
trunk/tests/phpunit/tests/blocks/wpBlock.php
r59116 r59761 716 716 717 717 /** 718 * @ticket 62901 719 */ 720 public function test_build_query_vars_from_query_block_with_top_level_parent() { 721 $this->registry->register( 722 'core/example', 723 array( 'uses_context' => array( 'query' ) ) 724 ); 725 726 $parsed_blocks = parse_blocks( '<!-- wp:example {"ok":true} -->a<!-- wp:example /-->b<!-- /wp:example -->' ); 727 $parsed_block = $parsed_blocks[0]; 728 $context = array( 729 'query' => array( 730 'postType' => 'page', 731 'parents' => array( 0 ), 732 ), 733 ); 734 $block = new WP_Block( $parsed_block, $context, $this->registry ); 735 $query = build_query_vars_from_query_block( $block, 1 ); 736 737 $this->assertSame( 738 array( 739 'post_type' => 'page', 740 'order' => 'DESC', 741 'orderby' => 'date', 742 'post__not_in' => array(), 743 'tax_query' => array(), 744 'post_parent__in' => array( 0 ), 745 ), 746 $query 747 ); 748 } 749 750 /** 718 751 * @ticket 56467 719 752 */
Note: See TracChangeset
for help on using the changeset viewer.