-
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
Fixes #26010 - Template Part Not Found message on Windows server #26772
Fixes #26010 - Template Part Not Found message on Windows server #26772
Conversation
…, reproducable ordering
…, reproducable ordering
…ns\gutenberg-source
…Otherwise Windows may return 2.
@@ -40,7 +40,7 @@ function render_block_core_template_part( $attributes ) { | |||
// Else, if the template part was provided by the active theme, | |||
// render the corresponding file content. | |||
$template_part_file_path = get_stylesheet_directory() . '/block-template-parts/' . $attributes['slug'] . '.html'; | |||
if ( 0 === validate_file( $template_part_file_path ) && file_exists( $template_part_file_path ) ) { | |||
if ( 0 === validate_file( $attributes['slug'] ) && file_exists( $template_part_file_path ) ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you know what's the purpose of this validate_file call? Why not just remove it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's to stop directory traversal.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for being patient here even for a small change. I appreciate it.
Description
In
gutenberg_render_block_core_template_part
when trying to find the template part from the theme's files, rather than callingvalidate_file()
against the full file name, we just validate the slug part. This overcomes the problem that in a Windows server the return code is 2 when the file name contains the drive letter ( egC:
).How has this been tested?
Screenshots
Without the fix the Template Part Not Found message is displayed twice.
With the fix the header and footer templates are found.
Types of changes
Bug fix for #26010. This only fixes the problem as reported.
It does not improve on the message "Template Part Not Found".
That's for later.
Checklist: