Themes: Avoid errors in some environments from `_get_block_templates_paths`.

This adds an `is_dir()` check in `_get_block_templates_paths` before trying to run a `RecursiveDirectoryIterator` to avoid errors being reported in New Relic even thought the errors should be handled by a try/catch block.

Follow-up to [57215].

Props iCaleb, sean212, mukesh27, joemcgill.
Fixes #60915.


Built from https://develop.svn.wordpress.org/trunk@57928


git-svn-id: http://core.svn.wordpress.org/trunk@57429 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Joe McGill 2024-04-04 18:56:57 +00:00
parent 78d729602e
commit 9bb63fd665
2 changed files with 2 additions and 4 deletions

View File

@ -229,14 +229,12 @@ function _get_block_templates_paths( $base_directory ) {
return $template_path_list[ $base_directory ];
}
$path_list = array();
try {
if ( is_dir( $base_directory ) ) {
$nested_files = new RecursiveIteratorIterator( new RecursiveDirectoryIterator( $base_directory ) );
$nested_html_files = new RegexIterator( $nested_files, '/^.+\.html$/i', RecursiveRegexIterator::GET_MATCH );
foreach ( $nested_html_files as $path => $file ) {
$path_list[] = $path;
}
} catch ( Exception $e ) {
// Do nothing.
}
$template_path_list[ $base_directory ] = $path_list;
return $path_list;

View File

@ -16,7 +16,7 @@
*
* @global string $wp_version
*/
$wp_version = '6.6-alpha-57926';
$wp_version = '6.6-alpha-57928';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.