Skip to content

Template Part Not Found message from gutenberg_render_block_core_template_part() on Windows server #26010

@bobbingwide

Description

@bobbingwide

Describe the bug
I'm following the instructions to develop a theme for Full Site Editing at
https://developer.wordpress.org/block-editor/tutorials/block-based-themes/
and received the following message "Template Part Not Found" on my Windows server.

I discovered that validate_file() returns 2 for a fully qualified file e.g.
C:/apache/htdocs/wp56/wp-content/themes/fizzie/block-template-parts/header.html.

gutenberg_render_block_core_template_part() doesn't cater for this value.
So the function fails to load the template part.

To reproduce
Steps to reproduce the behavior:

  1. On a Windows server
  2. Follow instructions to develop a theme for Full Site Editing
  3. View some content. e.g. Visit site.
  4. See the Template Part Not Found as part of the output.

Expected behavior
Code should be able to load template part files in a Windows server environment.

I suggest either change the logic to support a return value of 2 from validate_file().
or don't call validate_file() and validate the value for the slug attribute.

Screenshots
image

If applicable, add screenshots to help explain your problem.

Editor version (please complete the following information):

  • WordPress version: [e.g: 5.3.2] 5.5.1
  • Does the website has Gutenberg plugin installed, or is it using the block editor that comes by default? [e.g: "gutenberg plugin", "default"] Gutenberg 5.5.1 with Full Site Editing selected.
  • If the Gutenberg plugin is installed, which version is it? [e.g., 7.6]

Desktop (please complete the following information):

  • OS: [e.g. iOS] Windows
  • Browser [e.g. chrome, safari] Chrome
  • Version [e.g. 22]

Additional context

I've implemented a local fix

$valid = validate_file( $template_part_file_path );
if ( ( 0 === $valid || 2 == $valid )  && file_exists( $template_part_file_path ) ) {
	$content = file_get_contents( $template_part_file_path );
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Good First IssueAn issue that's suitable for someone looking to contribute for the first time[Block] Template PartAffects the Template Parts Block[Feature] ThemesQuestions or issues with incorporating or styling blocks in a theme.[Type] BugAn existing feature does not function as intended

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions