Make WordPress Core


Ignore:
Timestamp:
04/09/2024 01:23:21 AM (2 years ago)
Author:
joemcgill
Message:

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.

Location:
branches/6.5
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/6.5

  • branches/6.5/src/wp-includes/block-template-utils.php

    r57802 r57947  
    230230        }
    231231        $path_list = array();
    232         try {
     232        if ( is_dir( $base_directory ) ) {
    233233                $nested_files      = new RecursiveIteratorIterator( new RecursiveDirectoryIterator( $base_directory ) );
    234234                $nested_html_files = new RegexIterator( $nested_files, '/^.+\.html$/i', RecursiveRegexIterator::GET_MATCH );
     
    236236                        $path_list[] = $path;
    237237                }
    238         } catch ( Exception $e ) {
    239                 // Do nothing.
    240238        }
    241239        $template_path_list[ $base_directory ] = $path_list;
Note: See TracChangeset for help on using the changeset viewer.