From 7a5bc0367dd840832c43a858b3e3488e63879203 Mon Sep 17 00:00:00 2001 From: Joe McGill Date: Tue, 9 Apr 2024 01:25:17 +0000 Subject: [PATCH] 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 --- wp-includes/block-template-utils.php | 4 +--- wp-includes/version.php | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/wp-includes/block-template-utils.php b/wp-includes/block-template-utils.php index cfae702dd6..8ba4874a4b 100644 --- a/wp-includes/block-template-utils.php +++ b/wp-includes/block-template-utils.php @@ -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; diff --git a/wp-includes/version.php b/wp-includes/version.php index 1906698107..cd94bd9485 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @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.