Make WordPress Core

Opened 8 months ago

Closed 8 months ago

#58656 closed defect (bug) (duplicate)

The function _register_theme_block_patterns check to see if directory exist multiple times

Reported by: spacedmonkey's profile spacedmonkey Owned by:
Milestone: Priority: normal
Severity: normal Version: 6.2
Component: Editor Keywords: good-first-bug has-patch
Focuses: Cc:


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 ) ) {
        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)

#1 @spacedmonkey
8 months ago

  • Keywords good-first-bug needs-patch added

This ticket was mentioned in PR #4752 on WordPress/wordpress-develop by nirav7707.

8 months ago

  • Keywords has-patch added; needs-patch removed

Trac Ticket ->

  • ----

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.

#3 @spacedmonkey
8 months ago

#58655 was marked as a duplicate.

#4 @spacedmonkey
8 months ago

  • Milestone changed from Future Release to 6.4

#5 @spacedmonkey
8 months ago

  • Milestone 6.4 deleted
  • Resolution set to duplicate
  • Status changed from new to closed

Duplicate of #57905.

Fixed in [55702].

Note: See TracTickets for help on using tickets.