-
Notifications
You must be signed in to change notification settings - Fork 4.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow the query block to work on singular pages when inheriting the global query #28351
Conversation
Size Change: +25 B (0%) Total Size: 1.4 MB
ℹ️ View Unchanged
|
This is not safe as it would cause infinite loops when we have |
I just tested this and didn't see an issue... Could you elaborate on steps to replicate? |
In a single page:
|
Isn't it a general issue when using a Query block that contains Post Content child block and is embedded in the Post Content? Does it work any better when you explicitly pick posts (inherit option off) that contain Query block that nests Post Content? |
Yeah, this is not handled properly with just a small exception that with a custom query we use the value to exclude itself:
This doesn't catch cases of course with cyclic references.... Maybe we can land this as it solves the main purpose of Query block, that is FSE and revisit all this recursive problem? |
I'm more inclined to prevent those infinite recursions by marking blocks in their definitions as vulnerable to that. In particular, I mean here that Post Content block can't nest another Post Content. The same applies to Template Part and Reusable blocks. I'm sure there is more. |
Thank you both! |
IMO is not a blocker but I liked Miguel's approach and is fairly easy to to add it in this PR to |
@ntsekouras @gziolo Should we merge this one and deal with the recursion issue in a different PR (if it has not already been dealt with)? |
Yes, it makes sense to approach it this way 👍 |
@ntsekouras: I couldn't find a PR to address the recursion in Post Content. Do we have one, or should we start a new PR? The one for Reusable Blocks is merged (#28405) and the one for Template Parts is in progress (#28456). |
We don't have one and we should create one. |
Description
Fixes #28334
How has this been tested?
Tested in an FSE theme with only an
index.html
template containing a query block which inherits the global query.Before: The query was not rendering anything when viewing a
page
(works for posts).After: The query properly renders the contents of the page.
Types of changes
Added an extra check in the query loop. If the post-type is empty and we're on a singular post/page/cpt, it will use that post's post-type for the query.
Checklist:
I've included developer documentation if appropriate.I've updated all React Native files affected by any refactorings/renamings in this PR.