-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
FSE - infinity loop when search_template_hierarchy is empty #31652
Comments
I think the fundamental problem is in core. WordPress never had a representation in code of its template hierarchy. The hierarchy has in fact a "graphical representation" without a correspondent code representation. In the years, I approached that issue several times (e.g. here, a Composer package with over a 1.1 millions downloads). The logic in WordPress If WordPress would have a code representation of its template hierarchy, Gutenberg would be able to use that to determine which full-page template to use, instead of "hacking" WordPress and cause issues like the one in OP. I have the feeling that the issue caused by technical debt in WordPres code (that procedural procedure in Would not be better to address the issue in core, have a proper API around template hierarchy, and then make use of it in Gutenberg? That would be entirely doable in 100% backward compatible way, and would improve both WordPress and Gutenberg code. |
@gmazzap It's true that we've introduced FWIW, it's on the roadmap for WP 5.8 to move GB's block template resolution logic into Core, see e.g. this conversation. Looking for a more targeted solution for the present issue, I had another look at the function signatures of So we might make the third argument in |
Draft PR: #31671. |
I saw that, and that's IMO the problem. If something also listens to the same hooks using a later priority, what you store is not what people expect. Moreover, someone might have complex logic on I think that what is needed in the core is a set of
at that point, the existing function get_page_template() {
return get_query_template( 'page', get_page_hierarchy(), false );
} You see that I passed By supporting a boolean 3rd argument for Having that in the core, WordPress would not need to change anything else, considering that all the But Gutenberg could then write a function that making use of the new
and use that to resolve the FSE template to use, instead of "hacking" with WP hooks. Maybe, after an FSE template would found, it could be passed through to the |
FSE causes following error:
Xdebug has detected a possible infinite loop, and aborted your script with a stack depth of '256' frames
with following Stack:
Description
Our Plugin hooks into the search and replaces the template. As "micro"-optimization we added following code:
This will clean up the template hierarchy and skips a few
file_exists
-call from WordPress core, because we just want 1 single search template which we know it exists.Following problem occurs:
search_template
$current_template
.$template_hierachy
is empty, Gutenberg tries to callget_template_hierarchy( $template_type )
get_search_template()
,get_query_template()
get_query_template()
thesearch_template
-filter (see 1.) is applied again.An infinity loop is born. :)
WordPress information
The text was updated successfully, but these errors were encountered: