#62901 closed defect (bug) (fixed)
Editor: Fix 'parents' argument validation for Query block
Reported by: |
|
Owned by: |
|
---|---|---|---|
Milestone: | 6.8 | Priority: | normal |
Severity: | normal | Version: | |
Component: | Editor | Keywords: | has-patch commit |
Focuses: | Cc: |
Description
The build_query_vars_from_query_block
doesn't allow specifying zero (0
) in the parent's array argument, which can be used to display on top-level pages.
Gutenberg PR: https://github.com/WordPress/gutenberg/pull/68983.
Change History (6)
This ticket was mentioned in PR #8245 on WordPress/wordpress-develop by @Mamaduka.
2 weeks ago
#1
- Keywords has-patch added
@peterwilsoncc commented on PR #8245:
2 weeks ago
#2
This looks good to me, I used the following to test it against trunk and this branch and it now behaves as expected. Are you able to put this in to the test suite?
/**
* @ticket 62901
*/
public function test_build_query_vars_from_query_block_with_top_level_parent() {
$this->registry->register(
'core/example',
array( 'uses_context' => array( 'query' ) )
);
$parsed_blocks = parse_blocks( 'ab' );
$parsed_block = $parsed_blocks[0];
$context = array(
'query' => array(
'postType' => 'page',
'parents' => array( 0 ),
),
);
$block = new WP_Block( $parsed_block, $context, $this->registry );
$query = build_query_vars_from_query_block( $block, 1 );
$this->assertSame(
array(
'post_type' => 'page',
'order' => 'DESC',
'orderby' => 'date',
'post__not_in' => array(),
'tax_query' => array(),
'post_parent__in' => array( 0 ),
),
$query
);
}
@Mamaduka commented on PR #8245:
2 weeks ago
#3
Thank you, @peterwilsoncc!
#4
@
2 weeks ago
- Keywords commit added
@Mamaduka I'm fine with the changeset + the related unit test case 👍
#5
@
2 weeks ago
- Owner set to Mamaduka
- Resolution set to fixed
- Status changed from new to closed
In 59761:
@Mamaduka commented on PR #8245:
2 weeks ago
#6
Note: See
TracTickets for help on using
tickets.
Gutenberg PR: https://github.com/WordPress/gutenberg/pull/68983
Trac ticket: https://core.trac.wordpress.org/ticket/62901