Opened 20 months ago
Closed 19 months ago
#58656 closed defect (bug) (duplicate)
The function _register_theme_block_patterns check to see if directory exist multiple times
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 6.2 |
Component: | Editor | Keywords: | good-first-bug has-patch |
Focuses: | Cc: |
Description
In the function _register_theme_block_patterns
check to see if a directory exists three files.
$dirpath = $theme->get_stylesheet_directory() . '/patterns/';
if ( ! is_dir( $dirpath ) || ! is_readable( $dirpath ) ) {
continue;
}
if ( file_exists( $dirpath ) ) {
$files = glob( $dirpath . '*.php' );
This calls is_dir
, is_readable
and file_exists
basically the same thing. This should be avoided.
Change History (5)
This ticket was mentioned in PR #4752 on WordPress/wordpress-develop by nirav7707.
20 months ago
#2
- Keywords has-patch added; needs-patch removed
Note: See
TracTickets for help on using
tickets.
Trac Ticket -> https://core.trac.wordpress.org/ticket/58656
In the pull request (PR), the changes were made to remove the is_dir and is_readable checks. These checks were originally used to verify the availability of a directory. To streamline the code and avoid multiple checks, the is_readable function was used to validate the directory's existence and readability.
To implement this, an if condition was added with the negation of the is_readable check. If the condition is met, the continue statement is executed, skipping the rest of the code. However, if the directory is valid and readable, the remaining code is executed as usual.