Skip to content

Query Block: Fix 'parents' argument validation#68983

Merged
Mamaduka merged 2 commits intotrunkfrom
fix/query-loop-parents-argument-validation
Feb 4, 2025
Merged

Query Block: Fix 'parents' argument validation#68983
Mamaduka merged 2 commits intotrunkfrom
fix/query-loop-parents-argument-validation

Conversation

@Mamaduka
Copy link
Copy Markdown
Member

What?

Part of #68620

PR updates Query parents argument validation for hierarchical post types to allow querying only top-level entries, using "parents":[0].

Why?

  • A zero is a valid parent ID for hierarchical post types. Used to display top-level items.
  • Helps developers provide custom query patterns that only display top-level pages.

Testing Instructions

  1. Ensure you have a couple of pages with and without parents.
  2. Create a page.
  3. Add a Test Query using the code editor.
  4. Confirm that the Query block displays only the top-level items.

Testing Instructions for Keyboard

Same.

Test Query

Markup

<!-- wp:query {"queryId":1,"query":{"perPage":10,"pages":0,"offset":0,"postType":"page","order":"desc","orderBy":"date","author":"","search":"","exclude":[],"sticky":"","inherit":false,"parents":[0],"format":[]}} -->
<div class="wp-block-query"><!-- wp:post-template -->
<!-- wp:post-title /-->

<!-- wp:post-date /-->
<!-- /wp:post-template -->

<!-- wp:query-pagination -->
<!-- wp:query-pagination-previous /-->

<!-- wp:query-pagination-numbers /-->

<!-- wp:query-pagination-next /-->
<!-- /wp:query-pagination -->

<!-- wp:query-no-results -->
<!-- wp:paragraph {"placeholder":"Add text or blocks that will display when a query returns no results."} -->
<p></p>
<!-- /wp:paragraph -->
<!-- /wp:query-no-results --></div>
<!-- /wp:query -->

@Mamaduka Mamaduka added [Type] Bug An existing feature does not function as intended [Block] Query Loop Affects the Query Loop Block labels Jan 31, 2025
@Mamaduka Mamaduka self-assigned this Jan 31, 2025
@github-actions
Copy link
Copy Markdown

Flaky tests detected in ae0aa39.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/13071058461
📝 Reported issues:

Copy link
Copy Markdown
Contributor

@t-hamano t-hamano left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code looks good to me, but do we need to submit a PR against core along with this PR? This line.

@github-actions
Copy link
Copy Markdown

github-actions bot commented Feb 1, 2025

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: Mamaduka <mamaduka@git.wordpress.org>
Co-authored-by: t-hamano <wildworks@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@Mamaduka
Copy link
Copy Markdown
Member Author

Mamaduka commented Feb 1, 2025

The code looks good to me, but do we need to submit a PR against core along with this PR?

Yes. Didn't have time to create backport PR yesterday. Will do it Monday.

@Mamaduka Mamaduka force-pushed the fix/query-loop-parents-argument-validation branch from ae0aa39 to b09fe7d Compare February 3, 2025 15:03
Copy link
Copy Markdown
Contributor

@t-hamano t-hamano left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

@Mamaduka Mamaduka merged commit 06379a3 into trunk Feb 4, 2025
65 checks passed
@Mamaduka Mamaduka deleted the fix/query-loop-parents-argument-validation branch February 4, 2025 05:10
@github-actions github-actions bot added this to the Gutenberg 20.3 milestone Feb 4, 2025
Kallyan01 pushed a commit to Kallyan01/gutenberg that referenced this pull request Feb 24, 2025
Co-authored-by: Mamaduka <mamaduka@git.wordpress.org>
Co-authored-by: t-hamano <wildworks@git.wordpress.org>
chriszarate pushed a commit to chriszarate/gutenberg that referenced this pull request Jul 1, 2025
Co-authored-by: Mamaduka <mamaduka@git.wordpress.org>
Co-authored-by: t-hamano <wildworks@git.wordpress.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Block] Query Loop Affects the Query Loop Block [Type] Bug An existing feature does not function as intended

Projects

No open projects

Development

Successfully merging this pull request may close these issues.

2 participants