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]. Reviewed by jorbin. Merges [57928] to the to the 6.5 branch. Props iCaleb, sean212, mukesh27, joemcgill. Fixes #60915. Built from https://develop.svn.wordpress.org/branches/6.5@57947 git-svn-id: http://core.svn.wordpress.org/branches/6.5@57444 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
e4e1f40f0a
commit
7a5bc0367d
|
@ -229,14 +229,12 @@ function _get_block_templates_paths( $base_directory ) {
|
||||||
return $template_path_list[ $base_directory ];
|
return $template_path_list[ $base_directory ];
|
||||||
}
|
}
|
||||||
$path_list = array();
|
$path_list = array();
|
||||||
try {
|
if ( is_dir( $base_directory ) ) {
|
||||||
$nested_files = new RecursiveIteratorIterator( new RecursiveDirectoryIterator( $base_directory ) );
|
$nested_files = new RecursiveIteratorIterator( new RecursiveDirectoryIterator( $base_directory ) );
|
||||||
$nested_html_files = new RegexIterator( $nested_files, '/^.+\.html$/i', RecursiveRegexIterator::GET_MATCH );
|
$nested_html_files = new RegexIterator( $nested_files, '/^.+\.html$/i', RecursiveRegexIterator::GET_MATCH );
|
||||||
foreach ( $nested_html_files as $path => $file ) {
|
foreach ( $nested_html_files as $path => $file ) {
|
||||||
$path_list[] = $path;
|
$path_list[] = $path;
|
||||||
}
|
}
|
||||||
} catch ( Exception $e ) {
|
|
||||||
// Do nothing.
|
|
||||||
}
|
}
|
||||||
$template_path_list[ $base_directory ] = $path_list;
|
$template_path_list[ $base_directory ] = $path_list;
|
||||||
return $path_list;
|
return $path_list;
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
*
|
*
|
||||||
* @global string $wp_version
|
* @global string $wp_version
|
||||||
*/
|
*/
|
||||||
$wp_version = '6.5.1-alpha-57935';
|
$wp_version = '6.5.1-alpha-57947';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||||
|
|
Loading…
Reference in New Issue