Critical Error in Block Template Editor Due to Null Path in file_get_contents
Summary:
A critical error occurs when attempting to edit a template (specifically the single product template) in the WordPress admin. The error is triggered in the WooCommerce plugin file BlockTemplateUtils.php at line 226, where a file_get_contents() function is called with a null value instead of a valid file path.
The root cause appears to be an undefined path property on a WP_Block_Template object. The stack trace indicates that the error originates from the build_template_result_from_file method, which is called by the BlockTemplatesController while trying to add database templates. This suggests a problem in how the template's file path is being resolved or passed within the WooCommerce block system.
The impact is a complete failure of the template editor, preventing users from modifying templates and resulting in a white screen or critical error message. This issue was reproduced on a multisite environment with WordPress 6.8.1, PHP 7.4.33, the Twenty Twenty-Four theme, and WooCommerce 10.2.1, even with the Gutenberg plugin deactivated.
How to Replicate:
- Ensure the environment is running WordPress 6.8.1, WooCommerce 10.2.1, and a block-based theme like Twenty Twenty-Four.
- Navigate to the site's front end.
- Click the edit button for the single product template.
- The critical error will occur, preventing access to the editor.