mirror of
git://develop.git.wordpress.org/
synced 2025-02-21 23:22:31 +01:00
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. git-svn-id: https://develop.svn.wordpress.org/trunk@57928 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
fa16bb37b2
commit
ea7888f114
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user